-
Notifications
You must be signed in to change notification settings - Fork 646
Token: Add text alternative to close control #4799
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
Conversation
|
size-limit report 📦
|
| > | ||
| <Token as="a" href="/?path=/story/components-token-features--issue-label-token-custom-colors" text="Link" /> | ||
| <Token as="button" onClick={action('clicked')} text="Button" /> | ||
| <Token as="span" tabIndex={0} onFocus={action('focused')} text="Focusable Span" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change intentional? Seeing a lot of visual snapshot tests changed, but not sure if that's part of the PR
Update: Sorry, I understood why we are removing this! Didn't realise it was span with tab-index 😅🤷♀️
packages/react/src/Token/Token.tsx
Outdated
| onRemove, | ||
| id, | ||
| leadingVisual: LeadingVisual, | ||
| removeButtonLabel = 'Remove token', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering, is this a safe default? Where are Tokens used in dotcom and would it be obvious what "token" is referring to?
Open questions:
- Is no default better than confusing default?
- Is there a better default like
Remove ${props.text}?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup that's fair! I only kept it as Remove token since that was the default aria-label on it. We can definitely customize it a bit more, Remove "${props.text}" token.
Is no default better than confusing default?
Yeah, making consumers add the label themselves is sometimes the better option. In this case, since it's already using an aria-label="Remove token", I'm thinking the most backwards compatible way is to make it customizable while keeping the default? 🤔
Where are Tokens used in dotcom and would it be obvious what "token" is referring to?
Usage looks pretty limited ~ 3 instances, which is good! I think by adding ${props.text}, the "token" should be described in a way that users will know what it is.
| "name": "removeButtonLabel", | ||
| "type": "string", | ||
| "defaultValue": "'Remove token'", | ||
| "description": "Label to give to the remove button for assistive technologies, such as screen readers" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this API is becoming cumbersome because it feels like it's an after thought
We have 3 props onRemove, hideRemoveButton and removeButtonLabel that all affect one button and clash with each other :(
I'd love to clean this up in a backward compatible way. Do you think we could/should address that as part of this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point! I had a lot more planned for this PR, but unfortunately this is so intertwined with TextInputWithTokens it was hard to add meaningful changes without breaking something in that component 😕
I do think that we'd want to keep removeButtonLabel as there's no current way to change the "Remove token" aria-label attached on the token button now. I was planning on coming back to Token in https://github.com/github/primer/issues/3468, as this issue has the potential to require a lot of changes to both components.
We could remove removeButtonLabel and handle it later since that isn't part of any of the issues in https://github.com/github/primer/issues/3571, but an accessibility enhancement, or we could ship these changes and work towards making this component a bit cleaner and scope that into https://github.com/github/primer/issues/3468. Curious what you think though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could remove removeButtonLabel and handle it later ... and work towards making this component a bit cleaner and scope that into https://github.com/github/primer/issues/3468.
Sounds like a good plan! That will give us a good way to look at the API together
siddharthkp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple questions
|
@siddharthkp, with the idea of us rescoping some of the work needed for |
siddharthkp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request 1 change for removeButtonLabel, everything else looks great!
| "name": "removeButtonLabel", | ||
| "type": "string", | ||
| "defaultValue": "'Remove token'", | ||
| "description": "Label to give to the remove button for assistive technologies, such as screen readers" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could remove removeButtonLabel and handle it later ... and work towards making this component a bit cleaner and scope that into https://github.com/github/primer/issues/3468.
Sounds like a good plan! That will give us a good way to look at the API together
|
@siddharthkp, removed all instances of the prop! Should only consist of the storybook changes now |
| <TokenTextContainer {...(hasMultipleActionTargets ? interactiveTokenProps : {})}> | ||
| {text} | ||
| {onRemove && <VisuallyHidden> (press backspace or delete to remove)</VisuallyHidden>} | ||
| </TokenTextContainer> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just confirming this change: What does bringing onRemove inside the TokenTextContainer give us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one was a suggestion in this issue https://github.com/github/primer/issues/3582.
We're essentially adding the "(press backspace or delete to remove)" as part of the accessible name of the control instead of it being adjacent. This means that if a user using a screen reader tabs into a button token, their screen reader should announce {text} (press backspace or delete to remove). Outside of this PR, it can be easy to skip that text if you're just tabbing through interactive tokens, as you have to manually navigate by text to reach the message with a screen reader.
Now that I think about it a bit more, we could also use aria-describedby if we don't want to make this part of the accessible name, but also want to ensure that it won't be as easy to skip as it is currently 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, understood.
Let's run integration once just to make sure there are no jest tests that expect just the text to be present in the token
siddharthkp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Integration tests suggested, approving in advance
|
👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/341786 |
|
Tested in gh/gh, and integration tests look good! https://github.com/github/github/pull/341786 |
* Add new prop to `Token` * Remove `console.log` * Move text into control * Remove inaccessible examples * Add prop to docs * Add changeset * Update snapshots * Update text on prop * test(vrt): update snapshots * remove `removeButtonLabel` * Update snapshot * test(vrt): update snapshots --------- Co-authored-by: TylerJDev <TylerJDev@users.noreply.github.com>
Closes https://github.com/github/primer/issues/3582 https://github.com/github/primer/issues/3443
Changelog
New
removeButtonLabelChanged
Removed
Rollout strategy
Testing & Reviewing
Merge checklist