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

Provide instantiated tooltip object on initialized component #2139

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

wpears
Copy link
Member

@wpears wpears commented Jan 7, 2025

Some consumers of these tooltips may need access to the underlying tippy object to, eg, check the tooltip state, etc.
This PR provides the initialized tippy object as a tooltip key on the initialized component instance (this key is null before initialization).

@wpears wpears requested a review from anselmbradford January 7, 2025 19:21
Copy link

netlify bot commented Jan 7, 2025

Thanks for the improvements! Browse a preview of your changes using the link below.

Name Link
🔨 Latest commit 72163a3
🔍 Latest deploy log https://app.netlify.com/sites/cfpb-design-system/deploys/677ea8461dcc890008db7901
😎 Deploy Preview https://deploy-preview-2139--cfpb-design-system.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -25,7 +25,7 @@ function Tooltip(element) {
* @returns {Tooltip} An instance.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doc isn't quite right, is it? The returned type is whatever tippy returns, not an instance of Tooltip?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 72163a3

Copy link
Member

@anselmbradford anselmbradford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This felt a little redundant, because the init returns tippy, so why can't the returned value of init be stored in a variable? However, in Tooltip.init() we don't store the value of what is returned from init (here) and instead return a list of instances. The alternative to this would be to expose the returned value of init from within instantiateAll, but it seems reasonable to assume that a call to init would in general not be returning anything other than the instance itself. Therefore, the approach in this PR seems reasonable!

@wpears wpears merged commit 2a80be5 into main Jan 8, 2025
8 checks passed
@wpears wpears deleted the provide-tt-obj branch January 8, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants