Skip to content

Conversation

@broccolinisoup
Copy link
Member

@broccolinisoup broccolinisoup commented Jan 31, 2024

Changelog

New

Allow Tooltip to use the custom id to label/describe the trigger element

Changed

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

In the story, you can confirm that the custom id that is passed in the code is present in the dom.

Merge checklist

@changeset-bot
Copy link

changeset-bot bot commented Jan 31, 2024

🦋 Changeset detected

Latest commit: c93cffe

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

This PR includes changesets to release 1 package
Name Type
@primer/react 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

@broccolinisoup broccolinisoup changed the title tooltip v2 allow external id Tooltip v2: Allow external id to be passed down in tooltip so that the trigger can be labelled/described by the that id Jan 31, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Jan 31, 2024

size-limit report 📦

Path Size
dist/browser.esm.js 113.23 KB (-0.01% 🔽)
dist/browser.umd.js 113.86 KB (-0.02% 🔽)

Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

Looks great! Just had a question that I left as a comment and also wanted to ask if there was a test case that would cover this, as well 👀

export const Tooltip = React.forwardRef(
({direction = 's', text, type = 'description', children, ...rest}: TooltipProps, forwardedRef) => {
const tooltipId = useId()
const tooltipId = useId(rest.id)
Copy link
Member

Choose a reason for hiding this comment

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

Wanted to ask, is there a specific reason to not destructure this off of props? It doesn't seem like id as an identifier is used and could prevent potential bugs in the future if the position of {...rest} changes (like if someone accidentally moves it after where id={tooltipId} is set.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great point! I used rest.id because id isn't a defined prop like text or children but I guess it doesn't matter though and it is not very safe. Thanks for the comment! I updated it and added tests ✨ c93cffe

@broccolinisoup broccolinisoup force-pushed the tooltip-v2-allow-external-id branch from ee85bc2 to c93cffe Compare February 2, 2024 04:39
@broccolinisoup broccolinisoup added this pull request to the merge queue Feb 6, 2024
Merged via the queue into main with commit dc98814 Feb 6, 2024
@broccolinisoup broccolinisoup deleted the tooltip-v2-allow-external-id branch February 6, 2024 01:29
@primer primer bot mentioned this pull request Feb 6, 2024
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.

3 participants