Ability to close tooltips on Escape key
See original GitHub issueHey! Thanks for a great package 💞 It vastly simplified me working with Popper and creating dropdowns!
One thing that’s kinda common for popovers/dropdowns is to close them on <kbd>escape</kbd> key. Could this fit into this package, you think?
The requirements could be something like:
- Make it close on
keydownevent, with key <kbd>escape</kbd> as default. - Provide a way to opt out of the default behaviour (
closeOnEscape: falseas a passed prop).
I guess one can implement support for super custom cases here, like the ability for consumers to decide what DOM event and what key should trigger the close, but I think it’d be nice to keep it simple for now.
Let me know if I can help out with a PR.
I’ve implemented a quick fix in a fork of mine in the meantime, which code you can view here: https://github.com/brookback/react-popper-tooltip/pull/1.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Escape key should close any open tooltip · Issue #159 ...
It is a common convention that the escape key will close any open modal or overlay items, so the escape key should close...
Read more >jquery tooltip close on esc key - Stack Overflow
Our webpage, the tooltip works fine on mouse over. I need it close on esc key. I used many times to fix it....
Read more >ARIA Tooltip Example - Accessibility at Athena ICT
The tooltip widget can be hidden by pressing the Escape key; The tooltip is only hidden via JavaScript and CSS selectors. If JavaScript...
Read more >Tool tip present with 'Hover over me' button should get close ...
Tool tip present with 'Hover over me' button should get close by pressing esc key on the menu action feature.. DCDale Chen [MSFT]....
Read more >Filter tooltip lost its focus when closed by press...
Filter tooltip lost its focus when closed by pressing ESC key when it is published · 1) Enter in any chart in report...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks, I refactored the code after I pushed the comment but didn’t reload the page. Fixed now.
You’re right about the
refdocs. @mohsinulhaq wasn’t clear enough. I didn’t understand this prop at all before I implemented the example above.We can start the recipes from this case.
We’re going to remove a ref part from README. To implement close on Esc feature external state with
tooltipShownandonVisibilityChangeshould be used.I will provide an example after #11 merged.