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(toggle): allow to be labelled by another element #12974

Merged
merged 4 commits into from
Jan 19, 2023

Conversation

janhassel
Copy link
Member

Closes #12896

Implements the behaviour outlined in #12896 (comment) (option 2).

See "Testing / Review" at the end of this PR for details.

Changelog

New

  • Explicitly add aria-labelledby as optional prop for Toggle

Changed

  • Adjusted props.labelText validation for Toggle
  • Allow for toggle to be labelled by another element
  • Updated tests for Toggle

Testing / Reviewing

  • If props.hideLabel === true and props['aria-labelledby] IS NOT passed:
    • Render props.labelText on the side (instead of props.labelA and props.labelB
    • The .cds--toggle__label is a <label>
    • The .cds--toggle__label has a for attribute pointing to the <button> id (props.id)
  • If props.hideLabel === true and props['aria-labelledby] IS passed:
    • Don't render any side label (.cds--toggle__text) doesn't exist
    • The .cds--toggle__label is a <div>
  • If props.hideLabel === false and props['aria-labelledby] IS passed:
    • The .cds--toggle__label is a <div>
    • props.labelText is rendered on top of the toggle
  • If props.hideLabel === false and props['aria-labelledby] IS passed and props.labelText IS NOT passed:
    • The .cds--toggle__label is a <div>
    • .cds--toggle__label-text doesn't exist

@janhassel janhassel requested review from a team as code owners January 13, 2023 09:40
@netlify
Copy link

netlify bot commented Jan 13, 2023

Deploy Preview for carbon-components-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit d077a92
🔍 Latest deploy log https://app.netlify.com/sites/carbon-components-react/deploys/63c90428155d0c0009a3ddbd
😎 Deploy Preview https://deploy-preview-12974--carbon-components-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 settings.

@netlify
Copy link

netlify bot commented Jan 13, 2023

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit d077a92
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/63c9042859600400092ad150
😎 Deploy Preview https://deploy-preview-12974--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 settings.

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! 🎉

Copy link
Collaborator

@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, thanks for adding this in Jan 🎉

@kodiakhq kodiakhq bot merged commit d620d10 into carbon-design-system:main Jan 19, 2023
@janhassel janhassel deleted the 12896 branch January 19, 2023 14:43
@carbon-bot
Copy link
Contributor

Hey there! v11.21.0 was just released that references this issue/PR.

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]: Toggle ignores labelA and labelB and uses labelText if hideLabel is specified
4 participants