-
Notifications
You must be signed in to change notification settings - Fork 470
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(@clayui/navigation-bar): Add sr-only description for mobile view #5860
Conversation
042db77
to
426033c
Compare
@@ -118,6 +122,7 @@ function ClayNavigationBar({ | |||
<span className="navbar-text-truncate"> | |||
{triggerLabel} | |||
</span> | |||
<span className="sr-only">{itemLabel}</span> |
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.
Instead of sr-only
, I think it's better if we use aria-label
on the button instead. I think we need to be able to pass in a custom message to the aria-label
for translation purposes.
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.
Ah I see, I will make that change
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.
@pat270 I made the change but for some reason I was not able to run yarn develop to test it, are you able to test this one? I am not sure why the CI/test check is failing as well, it looks unrelated to my changes
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.
@SelenaAungst you need to recreate the test snapshots by running yarn test -u
. Since you updated the HTML this is reflected in the snapshot tests which are a way to ensure that the DOM remains the same. We only update the snapshot when the DOM change is intentional like your use case, just to avoid regressions.
In relation to this we should move this to be configured via props in the component, something like:
<ClayNavigationBar
messages={{
close: 'Close',
open: 'Open',
trigger: '{0} Menu, Current Page: {1}',
}}
>
{...}
</ClayNavigationBar>
So internally you can use these properties to form the aria-label
of the trigger.
<ClayButton
aria-expanded={expanded}
aria-label={sub(
messages.trigger,
[expanded ? messages.close : messages.open, triggerLabel]
)}
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.
Ah got it, thanks @matuzalemsteles! So do the ClayNavigationBar props still go in index.tsx or somewhere else? I will make the change to aria-label and run yarn test -u after this is complete.
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.
So do the ClayNavigationBar props still go in index.tsx or somewhere else?
Yes, you just need to define this new API type in the component props as well and add the type.
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.
Thanks @matuzalemsteles! I tried to add these changes and update tests. I am not positive this is correct so please let me know if there are any additional changes I can make.
0d12c2c
to
9de79c8
Compare
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.
@SelenaAungst looks good, just adding a comment to avoid a possible breaking change issue I forgot to mention.
@@ -64,6 +73,7 @@ function ClayNavigationBar({ | |||
fluidSize, | |||
inverted = false, | |||
itemAriaCurrent: ariaCurrent = true, | |||
messages, |
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.
Just to avoid the problem of breaking changes in components, we can add a default value here. This way, whoever is using it will not see the application build breaking.
messages, | |
messages = { | |
close: 'Close', | |
open: 'Open', | |
trigger: '{0} Menu, Current Page: {1}', | |
} |
/** | ||
* Defines aria-label messages to display for the screen reader. | ||
*/ | ||
messages: { |
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.
Here we also need to make this API optional to avoid the same problem I mentioned above.
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.
I added the default values, let me know if it looks good @matuzalemsteles
9de79c8
to
fd7f4c7
Compare
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.
LGTM! I think the build that is failing is not related to your changes.
https://liferay.atlassian.net/browse/LPD-29692