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

Attribute to control which attribute is set for title #256

Open
silverwind opened this issue Apr 9, 2023 · 2 comments
Open

Attribute to control which attribute is set for title #256

silverwind opened this issue Apr 9, 2023 · 2 comments

Comments

@silverwind
Copy link

silverwind commented Apr 9, 2023

Currently the element always sets the title attribute, but to implement a custom tooltip solution, it would be nice for it to set a different HTML attribute. How about a property titleAttribute="title", that could for example be set to aria-label?

@keithamus
Copy link
Member

We explored aria-label in #243 but it’s not the correct behaviour for this element, as it isn’t a focusable or otherwise interactive element. title isn’t necessarily correct either but right now it seems to be the least worst way of handling this.

I’m hesitant to introduce an attribute to customise this for two reasons:

  1. The element should always just do the correct thing. If title is wrong we should fix it to be correct.
  2. We should prevent users from doing the accidentally incorrect thing. Being able to set the attribute to something like aria-label which seems to be worse for accessibility (based on our testing) should not be possible.

@silverwind
Copy link
Author

One particular use of non-title tooltips is that they can allow the interactive selection of the value, which I find useful for referencing a date. Hover the time element, move mouse into tooltip, select and copy. Such interaction is not possible with title.

Currently I've implemented this via a one-time attribute value swap at page load and a MutationObserver to catch newly added elements, but it feels suboptimal.

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

2 participants