-
Notifications
You must be signed in to change notification settings - Fork 28
fix: use actual buttons in pager #498
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
base: main
Are you sure you want to change the base?
Conversation
3ee1f26 to
a0e7412
Compare
projects/ngx-datatable/src/lib/components/footer/pager.component.spec.ts
Show resolved
Hide resolved
BREAKING CHANGE: The pager component now uses buttons instead of anchors.
We did this change to properly reflect the nature of those buttons,
which have never been anchors in terms of behavior.
This change affects custom themes. Please adjust them accordingly:
```scss
// Before
.datatable-pager li a {
// styling
}
// After
.datatable-pager .page-button {
// Override default button styles
border: 0;
background none;
// previous styling
}
```
a0e7412 to
18ff14d
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.
Pull Request Overview
This PR refactors the pagination component by replacing anchor (<a>) elements with semantic button (<button>) elements for pager controls. This is a significant accessibility and semantic improvement, as buttons are the appropriate HTML element for interactive controls that perform actions rather than navigate to URLs.
Key Changes:
- Converted all pager anchor tags to button elements with
type="button"andclass="page-button" - Replaced class-based disabled state (
.disabledon<li>) with the nativedisabledattribute on buttons - Removed explicit keyboard event handlers (
keydown.enter,keydown.space) as buttons natively handle these - Updated CSS selectors across all themes (material, dark, bootstrap) from
ato.page-button - Updated test harness to query buttons directly and check
disabledproperty instead of class names - Updated E2E tests to use
toBeDisabled()matchers instead of checking for class names
Reviewed Changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pager.component.ts | Converted anchor tags to buttons with native disabled state and removed redundant keyboard handlers |
| pager.harness.ts | Updated selectors to target .page-button and changed disabled checks from class-based to property-based |
| pager.component.spec.ts | Removed keyboard navigation tests (now handled natively by buttons) and updated selector queries |
| pager.component.scss | Changed selectors from a to .page-button with disabled state styling |
| material.scss | Updated pager styling to use .page-button selector and :disabled pseudo-class |
| dark.scss | Updated pager styling to use .page-button selector (contains selector bug) |
| bootstrap.scss | Updated pager styling to use .page-button selector with correct :disabled pseudo-class |
| paging.spec.ts | Updated E2E tests to use button selectors and toBeDisabled() assertions |
| (various .png files) | Updated visual regression test snapshots reflecting the styling changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| border: 0; | ||
| background: none; | ||
|
|
||
| &:not(.disabled) { |
Copilot
AI
Nov 9, 2025
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.
The selector &:not(.disabled) should be &:not(:disabled) to correctly target enabled buttons. HTML button elements use the :disabled pseudo-class, not a .disabled CSS class. This inconsistency means disabled buttons will still receive hover/active styling.
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.
Agree, this seems to be a left-over from the old code, the other areas (e.g. https://github.com/siemens/ngx-datatable/pull/498/files#diff-eccd3293f095264b067c6f8bc5009e77fad64f7ef548e9885398c6ecd7e5f9eaR26) were adapted accordingly.
| :disabled { | ||
| cursor: not-allowed; |
Copilot
AI
Nov 9, 2025
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.
The :disabled pseudo-class selector should use &:disabled instead of :disabled. Without the &, this selector will look for disabled children of .page-button rather than the button itself being disabled.
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.
Hahahha, I was also wondering since there is only the icon as an inner-child, but the button itself should be marked as disabled, see https://github.com/siemens/ngx-datatable/pull/498/files#diff-21694ad3fc9021de26798e65a4abefe74e5682afde69e0159130a38859f55d19R34.
fh1ch
left a comment
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.
@spike-rabbit really cool stuff here, thanks a bunch 🙇
Just two open points and then we're good to go 🏓
| border: 0; | ||
| background: none; | ||
|
|
||
| &:not(.disabled) { |
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.
Agree, this seems to be a left-over from the old code, the other areas (e.g. https://github.com/siemens/ngx-datatable/pull/498/files#diff-eccd3293f095264b067c6f8bc5009e77fad64f7ef548e9885398c6ecd7e5f9eaR26) were adapted accordingly.
| :disabled { | ||
| cursor: not-allowed; |
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.
Hahahha, I was also wondering since there is only the icon as an inner-child, but the button itself should be marked as disabled, see https://github.com/siemens/ngx-datatable/pull/498/files#diff-21694ad3fc9021de26798e65a4abefe74e5682afde69e0159130a38859f55d19R34.
What kind of change does this PR introduce? (check one with "x")
What is the current behavior? (You can also link to an open issue here)
Pager is using anchors.
What is the new behavior?
Pager is using buttons.
Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications:
The pager component now uses buttons instead of anchors. We did this change to properly reflect the nature of those buttons, which have never been anchors in terms of their behavior.
This change affects custom themes. Please adjust them accordingly:
Other information:
This also fixes some alignment issues in the pager, causing multiple snapshot changes.