searchKeymap: own handling of "Escape" key

Hello,

I have the problem that I have a widget that surrounds the cm6 editor and it handles the Escape key.

I want to change the handling within the search addon so that the event doesn’t bubble up the DOM if I press the Escape key while focus is within the search panel’s input fields

Is that possible somehow in an easy way?

Thank you for your replies,
Simon

The recommended approach is to check for event.defaultPrevented in your outer handlers, and ignore events that have already been prevented. If that’s not practical, add a (low precedence) keydown handler to your editor that calls stopPropagation on all events that have their default behavior prevented.

1 Like

Thank you @marijn

I found another way to solve the problem for my case
Now I would still need the X Button on the search panel delete a state, so basically I’d need to change its behavior a bit. Is there an easy way?

Thank you for your time,
Simon

You could have your state field update function check searchPanelOpen and respond when that flips from true to false for a given transaction, maybe.