preventDefault in onKeyDown doesn't appear to do anything #1222
-
Hi, I'm trying to implement an onReturn key so that the text in the box is sent as a chat message when user clicks return. All working well until I use the mention combobox. If the user hits enter on one of the mention selections I would expect that key press to not be bubbling up to my onreturn plugin that is loaded after it. I can see in the getComboboxOnKeyDown line 62 it has event.preventDefault() which I thought was the way in which to stop that keyboard event from bubbling up to other plugins registered after it. This does not seem to be the case. However if I just create a dummy test plugin with an onKeyDown that does event.stopPropagation(), and load that before the combobox plugin, my plugin does prevent the enter key from bubbling to the combobox plugin. So my question is, is the intended functionality of the combobox plugin that event.preventDefault() is supposed to be blocking that enter key press from bubbling to other plugins so it can just capture the enter press to select the item from the combo box (which seems like the correct use to me). Or is it supposed to be bubbling that enter press? If it isn't intended for it to bubble out of the plugin, then is it a bug that it's using event.preventDefault, should it in fact be using event.stopPropergation? I see in lots of plugins they all use preventDefault() what is the intention of this as it doesn't appear to be doing anything? Cheers |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
found a solution, would still be good to confirm the intention. I can check event.defaultPrevented and not process my onReturn if it's already had preventDefault run. Which I'm assuming possibly is the intention. That way it still bubbles and you can decide to use the event if you want to even though it's already been processed. |
Beta Was this translation helpful? Give feedback.
found a solution, would still be good to confirm the intention.
I can check event.defaultPrevented and not process my onReturn if it's already had preventDefault run. Which I'm assuming possibly is the intention. That way it still bubbles and you can decide to use the event if you want to even though it's already been processed.