Skip to content

Conversation

@TylerJDev
Copy link
Member

@TylerJDev TylerJDev commented Jul 31, 2024

Closes https://github.com/github/primer/issues/3582 https://github.com/github/primer/issues/3443

Changelog

New

  • Add new prop removeButtonLabel

Changed

  • Moved visually hidden text into token container

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

Merge checklist

@TylerJDev TylerJDev self-assigned this Jul 31, 2024
@changeset-bot
Copy link

changeset-bot bot commented Jul 31, 2024

⚠️ No Changeset found

Latest commit: 08a9448

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions
Copy link
Contributor

github-actions bot commented Jul 31, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 97.05 KB (-0.02% 🔽)
packages/react/dist/browser.umd.js 97.46 KB (-0.01% 🔽)

@github-actions github-actions bot temporarily deployed to storybook-preview-4799 July 31, 2024 13:33 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4799 July 31, 2024 13:45 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4799 August 1, 2024 20:34 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4799 August 1, 2024 20:44 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4799 August 5, 2024 14:14 Inactive
@TylerJDev TylerJDev added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Aug 5, 2024
@github-actions github-actions bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Aug 5, 2024
@TylerJDev TylerJDev marked this pull request as ready for review August 5, 2024 14:29
@TylerJDev TylerJDev requested review from a team as code owners August 5, 2024 14:29
@TylerJDev TylerJDev requested a review from langermank August 5, 2024 14:29
@primer primer bot temporarily deployed to github-pages August 5, 2024 14:30 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4799 August 5, 2024 14:31 Inactive
@TylerJDev TylerJDev requested a review from siddharthkp August 5, 2024 15:20
>
<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" />
Copy link
Member

@siddharthkp siddharthkp Aug 13, 2024

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 😅🤷‍♀️

onRemove,
id,
leadingVisual: LeadingVisual,
removeButtonLabel = 'Remove token',
Copy link
Member

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}?

Copy link
Member Author

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"
Copy link
Member

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?

Copy link
Member Author

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!

Copy link
Member

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

Copy link
Member

@siddharthkp siddharthkp left a 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

@TylerJDev
Copy link
Member Author

@siddharthkp, with the idea of us rescoping some of the work needed for Token in https://github.com/github/primer/issues/3468, I'm wondering if this PR is good to be shipped? Since the two are intertwined, I was going to work towards adding more changes to Token in that issue, as the additions in this PR wouldn't need to be changed.

Copy link
Member

@siddharthkp siddharthkp left a 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"
Copy link
Member

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

@TylerJDev TylerJDev added the skip changeset This change does not need a changelog label Sep 11, 2024
@TylerJDev TylerJDev added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 11, 2024
@github-actions github-actions bot temporarily deployed to storybook-preview-4799 September 11, 2024 16:49 Inactive
@TylerJDev
Copy link
Member Author

@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>
Copy link
Member

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?

Copy link
Member Author

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 🤔

Copy link
Member

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

Copy link
Member

@siddharthkp siddharthkp 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!

Integration tests suggested, approving in advance

@primer-integration
Copy link

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/341786

@TylerJDev
Copy link
Member Author

Tested in gh/gh, and integration tests look good! https://github.com/github/github/pull/341786

@TylerJDev TylerJDev added this pull request to the merge queue Sep 12, 2024
Merged via the queue into main with commit f1196a8 Sep 12, 2024
@TylerJDev TylerJDev deleted the tylerjdev/token-a11y-fixes branch September 12, 2024 15:26
TylerJDev added a commit that referenced this pull request Sep 23, 2024
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility skip changeset This change does not need a changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants