You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When same handler is used for both a shortcut and button click, pressing Ctrl+Enter unexpectedly triggers a ClickEvent instead of TextareaShortcutEvent.
This is confusing because the handler's expected event type (TextareaShortcutEvent) is overwritten by ClickEvent from later registration.
I understand that defining separate handlers for keyboard and mouse events is the correct solution, since event types should naturally correspond to their components.
This is confusing because event types should be determined by the component (button → ClickEvent, shortcut → TextareaShortcutEvent), but instead they are determined by handler registration order.
Having event types determined by registration order or handler assignment makes the behavior unpredictable and breaks the natural component-event relationship.
This happens because register_event_handler function overwrites event type mappings.
Describe the bug
When same handler is used for both a shortcut and button click, pressing Ctrl+Enter unexpectedly triggers a ClickEvent instead of TextareaShortcutEvent.
This is confusing because the handler's expected event type (
TextareaShortcutEvent
) is overwritten byClickEvent
from later registration.To Reproduce
Steps to reproduce the behavior:
/page1
and focus on the textarea and press Ctrl+Enter (works fine)/page2
and focus on the textarea and press Ctrl+Enter (unexpectedly triggers ClickEvent)Expected behavior
Screenshots
When focusing on the textarea and press Ctrl+Enter:
Desktop System Info
Additional context
I understand that defining separate handlers for keyboard and mouse events is the correct solution, since event types should naturally correspond to their components.
This is confusing because event types should be determined by the component (
button
→ClickEvent
,shortcut
→TextareaShortcutEvent
), but instead they are determined by handler registration order.Having event types determined by registration order or handler assignment makes the behavior unpredictable and breaks the natural component-event relationship.
This happens because
register_event_handler
function overwrites event type mappings.mesop/mesop/component_helpers/helper.py
Lines 374 to 382 in 69148c9
If it's difficult to fix this issue directly in the implementation, I would like to propose the following:
https://google.github.io/mesop/guides/event-handlers/#troubleshooting
The text was updated successfully, but these errors were encountered: