Skip to content
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

fix: BreadcrumbItem aria-current PropType fix #15052

Merged

Conversation

Tresau
Copy link
Contributor

@Tresau Tresau commented Oct 27, 2023

Closes #15034

BREAKING CHANGE as it makes a PropType more specific.

The PropType for 'aria-current' in BreadcrumbItem is to broad, this change makes the definition more specific to match AriaAttributes['aria-current']. Depends on #15033 as this PR is branched from that issue.

Changelog

New

  • n/a

Changed

  • aria-current proptypes of BreadcrumItem from string, bool to bool, 'false', 'true', 'page', 'step', 'location', 'date', 'time'

Removed

  • n/a

Testing / Reviewing

Verify that the storybook has updated PropTypes
Verify tests pass
image

The PropType definition for 'aria-current' is to broad.
Update the PropType to match AriaAttributes['aria-current']

BREAKING CHANGE: PropType is changed to be more specific
@netlify
Copy link

netlify bot commented Oct 27, 2023

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 10d9c7d
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/654d1400cde464000829a2e4
😎 Deploy Preview https://deploy-preview-15052--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Oct 27, 2023

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 009e8e2
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/654cfe987884a8000872e785
😎 Deploy Preview https://deploy-preview-15052--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Tresau
Copy link
Contributor Author

Tresau commented Oct 31, 2023

This will require a snapshot update but I am not certain how best to alter it, is there a command or a manual process?

@alisonjoseph
Copy link
Member

@Tresau-IBM you should able to run yarn test -u to update the snapshot, there is also a merge conflict that popped up

@Tresau
Copy link
Contributor Author

Tresau commented Nov 1, 2023

@Tresau-IBM you should able to run yarn test -u to update the snapshot, there is also a merge conflict that popped up

Thank you, will address merge conflict and update snapshot, thank you


export interface BreadcrumbItemProps
extends React.HTMLAttributes<HTMLLIElement> {
'aria-current'?: AriaAttributes['aria-current'];
Copy link
Member

Choose a reason for hiding this comment

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

The TypeScript types aren't bound by semver right now and are provided on an as-is basis. I think it's fine to specify this here. It won't be classified as a breaking change.

Comment on lines 105 to 117
BreadcrumbItem.propTypes = {
'aria-current': PropTypes.oneOfType([
PropTypes.bool,
PropTypes.oneOf([
'false',
'true',
'page',
'step',
'location',
'date',
'time',
] as const),
]),
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this warrants a breaking change either. The spec is quite clear on what values are allowed, though there is one exception (I bolded below for emphasis)

The aria-current attribute is a token type. Any value not included in the list of allowed values SHOULD be treated by assistive technologies as if the value true had been provided. If the attribute is not present or its value is an empty string or undefined, the default value of false applies and the aria-current state MUST NOT be exposed by user agents or assistive technologies.

So technically any string is allowable and coalesces to true. You could argue these proptypes (plus the typings from React) are incorrect, but I don't think this presents much risk to have specific strings instead of allowing any string. If we get user feedback that some use case is missed, we can roll back this change very easily.

Copy link
Contributor

@tw15egan tw15egan left a comment

Choose a reason for hiding this comment

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

LGTM 👍 ✅

auto-merge was automatically disabled November 9, 2023 17:16

Head branch was pushed to by a user without write access

@Tresau Tresau requested a review from a team as a code owner November 9, 2023 17:16
@Tresau Tresau requested a review from tw15egan November 9, 2023 17:28
@tw15egan tw15egan added this pull request to the merge queue Nov 9, 2023
Merged via the queue into carbon-design-system:main with commit 05e65b3 Nov 9, 2023
danoro96 pushed a commit to danoro96/carbon that referenced this pull request Jan 18, 2024
…5052)

* feat: add types for Breadcrumbs

* revert: undo PropType changes and supress TS error instead

* fix: update 'aria-current' to match standards

The PropType definition for 'aria-current' is to broad.
Update the PropType to match AriaAttributes['aria-current']

BREAKING CHANGE: PropType is changed to be more specific

* fix: update snapshot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Proptype for aria-current in BreadcrumbItem is incorrect
4 participants