Skip to content

Tooltip v2: Allow external id to be passed down in tooltip so that the trigger can be labelled/described by the that id - #4200

Merged
broccolinisoup merged 5 commits into
mainfrom
tooltip-v2-allow-external-id
Feb 6, 2024
Merged

Tooltip v2: Allow external id to be passed down in tooltip so that the trigger can be labelled/described by the that id#4200
broccolinisoup merged 5 commits into
mainfrom
tooltip-v2-allow-external-id

Conversation

@broccolinisoup

@broccolinisoupbroccolinisoup commented Jan 31, 2024

Copy link
Copy Markdown
Member

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

changeset-botBot commented Jan 31, 2024

Copy link
Copy Markdown

🦋 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
NameType
@primer/reactPatch

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

Comment threadsrc/drafts/Tooltip/Tooltip.tsx
@broccolinisoupbroccolinisoup changed the title tooltip v2 allow external idTooltip v2: Allow external id to be passed down in tooltip so that the trigger can be labelled/described by the that idJan 31, 2024
@github-actions

github-actionsBot commented Jan 31, 2024

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
dist/browser.esm.js113.23 KB (-0.01% 🔽)
dist/browser.umd.js113.86 KB (-0.02% 🔽)

@joshblackjoshblack left a comment

Copy link
Copy Markdown
Member

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 👀

Comment threadsrc/drafts/Tooltip/Tooltip.tsx Outdated
export const Tooltip = React.forwardRef(
({direction = 's', text, type = 'description', children, ...rest}: TooltipProps, forwardedRef) => {
const tooltipId = useId()
const tooltipId = useId(rest.id)

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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
broccolinisoupforce-pushed the tooltip-v2-allow-external-id branch from ee85bc2 to c93cffeCompareFebruary 2, 2024 04:39
@github-actions
github-actionsBottemporarily deployed to storybook-preview-4200 February 2, 2024 04:44 Inactive
@broccolinisoup
broccolinisoup added this pull request to the merge queueFeb 6, 2024
Merged via the queue into main with commit dc98814Feb 6, 2024
@broccolinisoup
broccolinisoup deleted the tooltip-v2-allow-external-id branch February 6, 2024 01:29
@primerprimerBot mentioned this pull request Feb 6, 2024
Sign up for freeto 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.

2 participants

@broccolinisoup@joshblack