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(@clayui/navigation-bar): Add sr-only description for mobile view #5860

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

SelenaAungst
Copy link
Member

@@ -118,6 +122,7 @@ function ClayNavigationBar({
<span className="navbar-text-truncate">
{triggerLabel}
</span>
<span className="sr-only">{itemLabel}</span>
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member Author

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

Copy link
Member

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]
  )}

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

@SelenaAungst SelenaAungst force-pushed the LPD-29692-2 branch 2 times, most recently from 0d12c2c to 9de79c8 Compare August 20, 2024 02:05
Copy link
Member

@matuzalemsteles matuzalemsteles left a 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,
Copy link
Member

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.

Suggested change
messages,
messages = {
close: 'Close',
open: 'Open',
trigger: '{0} Menu, Current Page: {1}',
}

/**
* Defines aria-label messages to display for the screen reader.
*/
messages: {
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

@matuzalemsteles matuzalemsteles left a 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.

@matuzalemsteles matuzalemsteles merged commit dc58ce6 into liferay:master Aug 23, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants