Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard accessible tooltip #107

Closed
abijames opened this issue May 26, 2016 · 3 comments
Closed

Keyboard accessible tooltip #107

abijames opened this issue May 26, 2016 · 3 comments

Comments

@abijames
Copy link

I am looking for a customisable tooltip to use in a project using React but it needs to be accessible to keyboard users (and screen readers).

Currently react-tooltip only activates on hover. To be accessible it needs to activate when focus is on the element (onfocus) and then close if ESC is pressed (as documented in https://www.w3.org/TR/wai-aria-practices/#tooltip).

Is this in your roadmap? Or can you point me to the events that would need to be changed to start the tooltip when the element is in focus?

@wwayne
Copy link
Collaborator

wwayne commented May 26, 2016

Yo can take a look at the attribute event, it may satisfy your requirement, <ReactTooltip event='focus' /> or <p data-tip='...' data-event='focus'>
If it not, you can try to update this method, that's the closet way to satisfy your requirement I think.

@wwayne wwayne closed this as completed Jun 16, 2016
@mackbrowne
Copy link

@wwayne is there a good way to do this yet? I need the exact same thing. I've determined the key code i need for esc is 27. How can i close the tooltip when this key is pressed using the event functionality you mentioned above?

@luknl
Copy link

luknl commented Sep 8, 2020

Hi, I was able to make it work this way, with onFocus, and onBlur:

<button
  type="button"
  aria-label="Close"
  data-tip="Delete"
  data-for="deleteDocument"
  // delete document (on click, and when selected with keyboard and pressing "enter" (as it's type button)
  onClick={() => this.delete(document)}
  // show/hide tooltip on element focus/blur
  onFocus={(e) => ReactTooltip.show(e.target)}
  onBlur={(e) => ReactTooltip.hide(e.target)}
>Delete icon</button>
<ReactTooltip id="deleteDocument" effect="solid" />

Hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants