USWDS - Tooltip: dynamic initialization#4955
Merged
thisisdano merged 8 commits intodevelopfrom Sep 26, 2022
Merged
Conversation
added 7 commits
September 19, 2022 16:29
- 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.
amyleadem
approved these changes
Sep 22, 2022
Contributor
amyleadem
left a comment
There was a problem hiding this comment.
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.
thisisdano
approved these changes
Sep 26, 2022
Contributor
thisisdano
left a comment
There was a problem hiding this comment.
Such a good improvement and a model for other components!
|
❤️ THANK YOU! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/offmethod 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 testand make sure the tests for the files you have changed have passed.