Skip to content

Improve pagination template accessibility with aria attributes and re…#9905

Open
kosbemrunal wants to merge 1 commit intoencode:mainfrom
kosbemrunal:improve-pagination-accessibility
Open

Improve pagination template accessibility with aria attributes and re…#9905
kosbemrunal wants to merge 1 commit intoencode:mainfrom
kosbemrunal:improve-pagination-accessibility

Conversation

@kosbemrunal
Copy link

This PR improves the accessibility of the pagination template by:

  • Adding aria-label attributes for better screen reader support
  • Adding rel="prev" and rel="next" for semantic navigation
  • Adding aria-disabled and tabindex="-1" for disabled states

These changes improve accessibility without modifying existing functionality or behavior.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves the DRF pagination “previous/next” template’s accessibility metadata by adding ARIA attributes and semantic link relations to help assistive technologies interpret pagination controls.

Changes:

  • Add rel="prev" / rel="next" to pagination links.
  • Add aria-label to the previous/next links.
  • Add aria-disabled="true" and tabindex="-1" for disabled pagination states.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{% if previous_url %}
<li class="previous">
<a href="{{ previous_url }}">&laquo; Previous</a>
<a href="{{ previous_url }}" rel="prev" aria-label="Previous page">&laquo; Previous</a>
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

The new aria-label value ("Previous page") is inconsistent with the existing pagination template (numbers.html uses aria-label="Previous"). Consider using the same label across pagination templates (and reusing the existing visible wording) to keep screen reader output consistent.

Copilot uses AI. Check for mistakes.
{% if next_url %}
<li class="next">
<a href="{{ next_url }}">Next &raquo;</a>
<a href="{{ next_url }}" rel="next" aria-label="Next page">Next &raquo;</a>
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

The new aria-label value ("Next page") is inconsistent with the existing pagination template (numbers.html uses aria-label="Next"). Consider using the same label across pagination templates (and reusing the existing visible wording) to keep screen reader output consistent.

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +8
<li class="previous disabled" aria-disabled="true">
<a href="#" tabindex="-1" aria-disabled="true">&laquo; Previous</a>
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

In the disabled state this link still has href="#", so it remains clickable for mouse/touch users even though it is marked aria-disabled and removed from the tab order. To avoid a mismatch between semantics and behavior (and prevent jumping to the top of the page), consider rendering a non-link element (e.g., span) or removing the href when disabled.

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +18
<li class="next disabled" aria-disabled="true">
<a href="#" tabindex="-1" aria-disabled="true">Next &raquo;</a>
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

In the disabled state this link still has href="#", so it remains clickable for mouse/touch users even though it is marked aria-disabled and removed from the tab order. To avoid a mismatch between semantics and behavior (and prevent jumping to the top of the page), consider rendering a non-link element (e.g., span) or removing the href when disabled.

Copilot uses AI. Check for mistakes.
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.

2 participants