My editor has an extension which adds a language selector using a ‘panel’ extension. I’ve recently tried adding a new extension which toggles on and off various extensions in my editor based on the whether the editor has focus. For example, I only want to enable highlightActiveLine
when the editor has focus. To do this, I’m using the focusChangeEffect
to makes calls to reconfigure
with the appropriate extensions.
This almost works! The problem I’m running into is that one of the extensions I want to remove on blur
is the language selector panel, and it appears that the editor triggers focusChangeEffect
with a focus of false
when I use the language selector. As a result, as soon as I drop the language selector down, the editor loses focus, and the language selector disappears.
My expectation was that the editor panel would be included in the focus of the editor, but that doesn’t seem to be the case. So I need another way to accomplish what I’m trying to do.
So my first question is: is this even the right way - at a high level - to approach the job of toggling extensions on and off based on focus?
Assuming this approach is correct (or that I use some other more correct approach), how do I ensure that my panel controls don’t steal focus from the editor, short-circuiting the ability to use them at all?