Ability to close tooltips on Escape key

See original GitHub issue

Hey! 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 keydown event, with key <kbd>escape</kbd> as default.
  • Provide a way to opt out of the default behaviour (closeOnEscape: false as 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:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
denisborovikovcommented, Sep 18, 2018

Thanks, I refactored the code after I pushed the comment but didn’t reload the page. Fixed now.

You’re right about the ref docs. @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.

1reaction
denisborovikovcommented, Sep 19, 2018

We’re going to remove a ref part from README. To implement close on Esc feature external state with tooltipShown and onVisibilityChange should be used.

I will provide an example after #11 merged.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found