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
Click the span below the menu button (for the mousedown event, we replace it with the input element)
Expected: The menu should get closed
Actual: The menu stays open
As I understand, when deciding whether to close the menu on click, this logic intentionally ignores this use-case, i.e. does not close it.
What do you think about making this logic somehow configurable?
Quick ideas:
An optional param shouldCloseMenuIfMouseDownTargetNotInDOM (or some better name :))
A more generic optional callback param shouldCloseMenu: (initialTarget: HTMLElement, eventualTarget: HTMLElement, <any other relevant args>) => boolean
An optional param shouldCloseMenuOnMouseDown (or a more general name that also covers the touchStart event). As the name suggests, if this is true, the menu would get closed on mouseDown/touchStart instead of on-click.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Example: https://stackblitz.com/edit/react-ts-1jsyjo?file=App.tsx
Reproduce:
Expected: The menu should get closed
Actual: The menu stays open
As I understand, when deciding whether to close the menu on click, this logic intentionally ignores this use-case, i.e. does not close it.
What do you think about making this logic somehow configurable?
Quick ideas:
shouldCloseMenuIfMouseDownTargetNotInDOM
(or some better name :))shouldCloseMenu: (initialTarget: HTMLElement, eventualTarget: HTMLElement, <any other relevant args>) => boolean
shouldCloseMenuOnMouseDown
(or a more general name that also covers thetouchStart
event). As the name suggests, if this is true, the menu would get closed on mouseDown/touchStart instead of on-click.Beta Was this translation helpful? Give feedback.
All reactions