How to tell if editor drawer is open?

Greetings! I just published my first plugin: https://github.com/bfillmer/subtle-wordcount

Things are working great, but I noticed that since the components are mounted the whole time the count updates “in the background”, even when the drawer is closed. To optimize I’d like to only get the count and re-render when the drawer is open, but I couldn’t find that piece of state in redux after digging around for a bit.

Any direction would be great!

Bryan

Hi Bryan,

Wow, that looks so cool :star_struck:

You are right, the drawer visibility state is not managed in redux.
At the moment, you can check if the drawer container .editor-drawer-container has visible class like so:

const container = document.querySelector('.editor-drawer-container')
container.classList.contains('visible') // -> true/false

Hope that helps!

1 Like