Check if select2 dropdown is open

I want to check if my select2 dropdown is open or not. Is there a property or another way that I can use to detect this?

I was wondering if there is a better way than creating a variable, listening to the open and close events, and keeping the status in that variable manually.

It seems none of the answers in this StackOverflow thread is working anymore.

I have not tested but you can try the below solution:
Open Developer Tools (Chrome) and then the tab ‘Elements’
When you click to open the select2 then a span element with class select2-container–open is displayed.
So you could check for existence of that class using for example jquery

Thank you! It works!