Skip to content

Make ToolTipElement for an observed attribute #3558

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

Merged

Conversation

myabc
Copy link
Contributor

@myabc myabc commented Jun 16, 2025

What are you trying to accomplish?

Make ToolTipElement for an observed attribute.

Enables the for attribute (and associated control element) to be dynamically added or updated after the custom element is connected to the DOM, allowing event listeners to be attached accordingly.

This improves compatibility with frontend frameworks (e.g. Angular) that bind attributes post-instantiation.

Integration

This change should not require any changes to production code.

List the issues that this change affects.

Closes #3557

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

What approach did you choose and why?

N/A

Anything you want to highlight for special attention from reviewers?

Tested with a recent version of Angular: opf/openproject#19121

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

@Copilot Copilot AI review requested due to automatic review settings June 16, 2025 18:28
@myabc myabc requested a review from a team as a code owner June 16, 2025 18:28
@myabc myabc requested a review from francinelucca June 16, 2025 18:28
Copy link

changeset-bot bot commented Jun 16, 2025

🦋 Changeset detected

Latest commit: 9b55c8c

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

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR makes the ToolTipElement support a new observed attribute "for" to improve interop with other frontend frameworks. Key changes include:

  • Adding "for" to the list of observed attributes.
  • Extracting the event listener and attribute update logic into a new method (#updateControl).
  • Adjusting attributeChangedCallback to call #updateControl when the "for" attribute changes.
Comments suppressed due to low confidence (1)

app/components/primer/alpha/tool_tip.ts:303

  • Confirm that updating the 'for' attribute triggers the correct re-association with the new control, and that any necessary cleanup or re-initialization is performed to avoid side effects.
if (name === 'for') {

@francinelucca
Copy link
Member

@myabc thanks for the contribution! can you add a changeset? You can do so running npx changesetin command line. I tried doing so but I don't have write permissions since its a fork

@myabc myabc force-pushed the feature/tool-tip-for-observed-attribute branch from ac0ad80 to 9cdb9d2 Compare June 19, 2025 12:52
myabc added 2 commits June 19, 2025 13:53
Enables the for attribute (and associated control element) to be
dynamically added or updated after the custom element is connected to
the DOM, allowing event listeners to be attached accordingly.

This improves compatibility with frontend frameworks that bind
attributes post-instantiation, enhancing interop in dynamic or reactive
rendering scenarios.

Closes primer#3557
@myabc myabc force-pushed the feature/tool-tip-for-observed-attribute branch from 9cdb9d2 to 9b55c8c Compare June 19, 2025 12:53
@myabc
Copy link
Contributor Author

myabc commented Jun 19, 2025

Hi @francinelucca Many thanks for looking at this PR! I've added the changeset - and will also update the description.

@francinelucca francinelucca added this pull request to the merge queue Jun 19, 2025
Merged via the queue into primer:main with commit 9cdefbb Jun 19, 2025
31 of 32 checks passed
@primer primer bot mentioned this pull request Jun 19, 2025
@myabc myabc deleted the feature/tool-tip-for-observed-attribute branch June 20, 2025 12:57
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

Successfully merging this pull request may close these issues.

Make ToolTipElement for attribute an observed attribute
2 participants