-
Notifications
You must be signed in to change notification settings - Fork 983
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
USWDS - Tooltip: dynamic initialization #4955
Conversation
- Create const for tooltip trigger class - Create function for getting tooltip elements - Show and hide default tooltips using behaviors - Remove title attribute on trigger instead of leaving it empty
Switched to using events in behaviors like other components. Export functions for setup, getting selectors, showing and hiding tooltip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool fix! I was able to dynamically add a tooltip that scaffolds itself and works as expected. Additionally, the tooltip works as expected with both mouse and keyboard in Safari, Firefox, Chrome and with touch in iOS and VoiceOver Gestures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such a good improvement and a model for other components!
❤️ THANK YOU! |
Summary
Tooltip initializes on first interaction. Tooltip now checks if it has been initialized before toggling. If it hasn't initialized properly then it will call a setup attributes function. Closes #4055.
Additional information
Component setup only occurred on document ready or when manually calling the
on/off
method on a specific element. This caused issues because:This PR does the following:
I've also removed the title attribute from tooltip trigger, instead of leaving it empty.
How to test
★ Dynamic tooltip example
Before you hit Submit, make sure you’ve done whichever of these applies to you:
npm test
and make sure the tests for the files you have changed have passed.