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

fix(@clayui/pagination): LPD-1285 accessibility issues on prev, next … #5779

Merged
merged 2 commits into from
Mar 8, 2024

Conversation

pat270
Copy link
Member

@pat270 pat270 commented Mar 6, 2024

…and ellipsis buttons

https://liferay.atlassian.net/browse/LPD-1285

This adds role="button" to the prev and next buttons. Axe flags these because there is no href attribute. This also adds aria-controls="clay-id-#" on the ellipsis button when it is active. The dropdown-menu is lazy loaded and Axe can't associate aria-controls to the dropdown-menu.

Axe Errors
accessibility-errors

After Fix
accessibility-fixed

@@ -164,6 +164,7 @@ const ClayPaginationWithBasicItems = React.forwardRef<HTMLUListElement, IProps>(
disabled={internalActive === 1}
href={previousHref}
onClick={() => setActive(previousPage)}
role={internalActive === 1 ? undefined : 'button'}
Copy link
Member

Choose a reason for hiding this comment

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

In both these cases shouldn't we be checking if the href is actually empty or null? Don't we sometimes use an href for going to the previous or next page, in which case the role should stay a link and not a button, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I'll update it

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

@@ -164,6 +164,11 @@ const ClayPaginationWithBasicItems = React.forwardRef<HTMLUListElement, IProps>(
disabled={internalActive === 1}
href={previousHref}
onClick={() => setActive(previousPage)}
role={
previousHref || internalActive === 1
Copy link
Member

Choose a reason for hiding this comment

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

If there is a previousHref, it will be a string which would be a truthy value. Then this would be set as the role, right? So I don't think this logic wouldn't be correct when previousHref exists.

Copy link
Member Author

Choose a reason for hiding this comment

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

If previousHref exists, the pagination component outputs <a class="page-link" href="/url">. In this case, we don't need role="button" because it's a hyperlink.

Copy link
Member

Choose a reason for hiding this comment

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

Okay... looks good. Sorry I was incorrectly interpreting the precedence of the operators.

Copy link
Member

@ethib137 ethib137 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -164,6 +164,11 @@ const ClayPaginationWithBasicItems = React.forwardRef<HTMLUListElement, IProps>(
disabled={internalActive === 1}
href={previousHref}
onClick={() => setActive(previousPage)}
role={
previousHref || internalActive === 1
Copy link
Member

Choose a reason for hiding this comment

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

Okay... looks good. Sorry I was incorrectly interpreting the precedence of the operators.

@matuzalemsteles matuzalemsteles merged commit 351b254 into liferay:master Mar 8, 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