-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add the role=button to search #7594
Add the role=button to search #7594
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This pull request adds the role='button' attribute to the search item in the main navigation drawer, improving accessibility for screen readers and assistive technologies.
- Added role='button' prop to search item in
packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerItems.tsx
- Implemented 'role' prop in
packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx
- Applied role attribute to StyledItem component in NavigationDrawerItem
- Change addresses issue Add role="button" to navbar search #7575, enhancing navbar search accessibility
- Modification is minimal and doesn't introduce apparent issues or side effects
2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -185,6 +187,7 @@ export const NavigationDrawerItem = ({ | |||
as={to ? Link : 'div'} | |||
to={to ? to : undefined} | |||
indentationLevel={indentationLevel} | |||
role={role} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Ensure role is only applied when it's a non-empty string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you a lot for contributing to Twenty! I wrote a comment to discuss the proposed solution with you and my colleagues 😄
@@ -185,6 +187,7 @@ export const NavigationDrawerItem = ({ | |||
as={to ? Link : 'div'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting role=button
is half a solution to make that component a button. Instead, we should render a <button>
HTML tag when we want to display a button. The as
property allows us to choose which component we want to render at the end. We should use it to display a button when we want.
Setting an HTML element's role
attribute is a last resort. We should always try to use semantic HTML first, and here, using a button
element makes sense.
To make it work with the current code, the NavigationDrawerItem
component could take an optional as
property which could be 'button' | undefined
. We could use it to choose which component to render.
Ok I will work on that |
This reverts commit efd7d9e.
4e06ddb
to
9fa5f78
Compare
Awarding DivyanshuLohani: 150 points 🕹️ Well done! Check out your new contribution on oss.gg/DivyanshuLohani |
In this PR:
<NavigationDrawerItem />
component render a<button>
by default instead of a<div>
<div>
by<span>
inside the<NavigationDrawerItem />
as<button>
and<a>
HTML elements only accept phrasing content.Fixes #7575