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

feat(Tab): autogenerate IDs #7519

Merged

Conversation

emyarod
Copy link
Member

@emyarod emyarod commented Jan 7, 2021

Closes #7511

This PR autogenerates tab IDs so that the prop remains optional but the functionality does not break if a value is not provided by the user

Changelog

Changed

  • autogenerate tab IDs by default

Removed

  • remove hard coded IDs in storybook examples

Testing / Reviewing

Confirm that tabs function as expected when an ID is not provided

@netlify
Copy link

netlify bot commented Jan 7, 2021

✔️ Deploy preview for carbon-elements ready!

🔨 Explore the source changes: 5bf5685

🔍 Inspect the deploy logs: https://app.netlify.com/sites/carbon-elements/deploys/600729c3a7267b00079a8428

😎 Browse the preview: https://deploy-preview-7519--carbon-elements.netlify.app

@netlify
Copy link

netlify bot commented Jan 7, 2021

✔️ Deploy preview for carbon-components-react ready!
Built without sensitive environment variables

🔨 Explore the source changes: 5bf5685

🔍 Inspect the deploy logs: https://app.netlify.com/sites/carbon-components-react/deploys/600729c21f08630007ca59f8

😎 Browse the preview: https://deploy-preview-7519--carbon-components-react.netlify.app

@@ -105,9 +106,11 @@ export default class Tab extends React.Component {
onKeyDown: () => {},
};

tabId = this.props.id || `tab-${getInstanceId()}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

One quick question, we've gotten some feedback around DOM mismatches when using auto-ids and server-side rendering. Curious if there is something we could do here, or if we're just saying if you want to SSR then you should pass in an id 👀

Reference for the useId hook for background (totally get we can't use the hook in a class component): https://github.com/carbon-design-system/carbon/blob/master/packages/react/src/internal/useId.js#L8

Copy link
Member Author

@emyarod emyarod Jan 11, 2021

Choose a reason for hiding this comment

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

we're just saying if you want to SSR then you should pass in an id

yeah this sounds logical to me, but how have we handled it previously? the auto-id generators can be found throughout the library currently so I thought it was a viable solution here

Copy link
Contributor

Choose a reason for hiding this comment

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

@emyarod sounds great to me, especially for the class components 👍

@andreancardona andreancardona merged commit 5e9ab8d into carbon-design-system:master Jan 19, 2021
@emyarod emyarod deleted the 7511-autogenerate-tab-ids branch January 20, 2021 15:23
@emyarod emyarod mentioned this pull request Jan 22, 2021
46 tasks
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.

Tab without id prop fails accessibility
4 participants