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

Update tooltip to run setup on connectedCallback instead of relying on attributeChangedCallback #1688

Merged
merged 2 commits into from
Dec 8, 2022

Conversation

manuelpuyol
Copy link
Contributor

Description

It looks like when we navigate using a Turbo Frame in dotcom, due to some Turbo internals,attributeChangedCallback runs before the element is added to the DOM tree. This causes control to not be found (since it's also not in the tree) and the setup is skipped. In this case, control will not have the correct aria- attributes.

With this change, I'm guaranteeing that the setup always runs when the tool-tip connects to the page.

Integration

Nope, this should be a no-op in terms of functionality

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews

@manuelpuyol manuelpuyol requested review from a team and camertron December 7, 2022 22:43
@changeset-bot
Copy link

changeset-bot bot commented Dec 7, 2022

🦋 Changeset detected

Latest commit: 77170e6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/view-components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the javascript Pull requests that update Javascript code label Dec 7, 2022
@manuelpuyol manuelpuyol temporarily deployed to github-pages December 7, 2022 22:49 — with GitHub Actions Inactive
Copy link
Contributor

@khiga8 khiga8 left a comment

Choose a reason for hiding this comment

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

Nice fix and cleanup!

In the past, we've run into issues with #updatePosition method being called on page load which led to performance issues on pages with hundreds of tooltips (since calculating position is expensive). It doesn't seem like this PR introduces that issue so this seems fine to me.

@jonrohan jonrohan merged commit 988077a into main Dec 8, 2022
@jonrohan jonrohan deleted the tooltip-lifecycle branch December 8, 2022 17:16
@primer-css primer-css mentioned this pull request Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants