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

chore: update warning in button component #1455

Merged
merged 6 commits into from
Mar 18, 2024
Merged

Conversation

Chisomchima
Copy link
Member

@Chisomchima Chisomchima commented Feb 16, 2024

Implements LIBS-565


Description

Implemented LIBS-565 by updating developer warning in button component. This change ensures that accessibility attributes can be easily included when using the Button component.


Known issues

  • None

Checklist

  • API docs are generated
  • Tests were added
  • Storybook demos were added

All points above should be relevant for feature PRs. For bugfixes, some points might not be relevant. In that case, just check them anyway to signal the work is done.


Screenshots

  • None

Additional Notes

  • Updated the Button component to destructure title and ariaLabel from otherProps and apply them to the <button> element.
  • Ensured that title and aria-label attributes are correctly passed to the rendered <button> element.
  • Modified the component to handle additional attributes passed as otherProps while maintaining accessibility.

supporting text

@Chisomchima Chisomchima requested a review from a team as a code owner February 16, 2024 13:05
@Chisomchima Chisomchima marked this pull request as draft February 16, 2024 13:07
@Chisomchima Chisomchima changed the title update warning in button component feat: update warning in button component Feb 16, 2024
@dhis2-bot
Copy link
Contributor

dhis2-bot commented Feb 16, 2024

🚀 Deployed on https://pr-1455--dhis2-ui.netlify.app

@dhis2-bot dhis2-bot temporarily deployed to netlify February 16, 2024 13:10 Inactive
Copy link

cypress bot commented Feb 16, 2024

Passing run #3249 ↗︎

0 584 0 0 Flakiness 0

Details:

feat: update warning in button component
Project: ui Commit: 2c94aef640
Status: Passed Duration: 07:01 💡
Started: Feb 21, 2024 11:13 AM Ended: Feb 21, 2024 11:20 AM

Review all test suite changes for PR #1455 ↗︎

@Chisomchima Chisomchima marked this pull request as ready for review February 16, 2024 13:32

if (!children && !title && !ariaLabel) {
console.debug(
'Button component has no children but is missing title or ariaLabel attribute.'
Copy link
Member

@Birkbjo Birkbjo Feb 16, 2024

Choose a reason for hiding this comment

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

Do we want to ariaLabel to fallback to title?

expect(consoleSpy).not.toHaveBeenCalled()
})

it('does not warn if aria-label or title is present', () => {
Copy link
Member

@Birkbjo Birkbjo Feb 16, 2024

Choose a reason for hiding this comment

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

This "or" should be "and" according to the test implementation, right? Could be more clear if we had two tests, where ariaLabel is passed in without title, and the opposite. But I guess that would make more sense without passing children?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, you're right, "and" seems like a better choice in this case.

@@ -37,6 +37,14 @@ export const Button = ({
}
}, [initialFocus, ref.current])

const { 'aria-label': ariaLabel, title } = otherProps
Copy link
Collaborator

Choose a reason for hiding this comment

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

not part of this PR - but I think ariaLabel in the previous tests should be updated to aria-label like in this test

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah we should make sure these are aria-label (not camelcased). This applies to your previous PR as well @d-rita - let's update them to make them consistent aria-*

In React, all DOM properties and attributes (including event handlers) should be camelCased. For example, the HTML attribute tabindex corresponds to the attribute tabIndex in React. The exception is aria-* and data-* attributes, which should be lowercased. For example, you can keep aria-label as aria-label.

https://legacy.reactjs.org/docs/dom-elements.html

Copy link
Member Author

Choose a reason for hiding this comment

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

alright

@dhis2-bot dhis2-bot temporarily deployed to netlify February 21, 2024 10:12 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify February 21, 2024 11:10 Inactive
@kabaros kabaros changed the base branch from master to alpha March 18, 2024 15:42
Copy link
Collaborator

@kabaros kabaros left a comment

Choose a reason for hiding this comment

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

approved - will merge to alpha

@kabaros kabaros force-pushed the LIBS-565/button-accessibility branch from 2c94aef to c8abea9 Compare March 18, 2024 15:51
@kabaros kabaros changed the title feat: update warning in button component chore: update warning in button component Mar 18, 2024
@kabaros kabaros merged commit 77b5f96 into alpha Mar 18, 2024
5 of 6 checks passed
@kabaros kabaros deleted the LIBS-565/button-accessibility branch March 18, 2024 15:52
@dhis2-bot dhis2-bot temporarily deployed to netlify March 18, 2024 16:03 Inactive
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 9.5.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 9.9.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 9.12.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 10.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

4 participants