Skip to content

fix: pagination keyboard controls#984

Merged
davedbase merged 5 commits into
nextfrom
fix/pagination-keyboard-controls
Jul 13, 2026
Merged

fix: pagination keyboard controls#984
davedbase merged 5 commits into
nextfrom
fix/pagination-keyboard-controls

Conversation

@atk

@atk atk commented Jul 9, 2026

Copy link
Copy Markdown
Member

When navigating the pagination with the keyboard, we could get into the situation where a button/link that previously had focus would be detached by the page switch, thus no longer having a parent reference to focus the current page. This is now fixed. Also, the stories broke whenever one switched the parameters. This is now rectified, too.

Addresses #286

Summary by CodeRabbit

  • Bug Fixes

    • Improved pagination keyboard navigation so focus remains on the active page button after changing pages.
    • Updated pagination accessibility labeling to correctly identify the current page.
  • Accessibility

    • Storybook buttons now support ARIA labels, current-page indicators, and keyboard event handling.
  • Tests

    • Added coverage confirming focus is preserved during keyboard-based page navigation.

@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cf83ad1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solid-primitives/pagination Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@atk atk changed the base branch from main to next July 9, 2026 07:46
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 664b110c-9aff-4afe-9d95-0b03489af5c2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pagination-keyboard-controls

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 9, 2026

Copy link
Copy Markdown

Deploying solid-primitives with  Cloudflare Pages  Cloudflare Pages

Latest commit: cf83ad1
Status:🚫  Build failed.

View logs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.storybook/ui/controls.tsx:
- Around line 1-8: Update the Button props’ onClick and onKeyUp types to use
Solid’s JSX.EventHandlerUnion for HTMLButtonElement with the corresponding event
types, or reuse JSX.ButtonHTMLAttributes, so tuple-form handlers passed from
pagination remain assignable.

In `@packages/pagination/src/index.ts`:
- Around line 171-183: Update goPage’s parent lookup to target the pagination
component directly, using the nearest nav ancestor or an equivalent
pagination-specific data attribute instead of the childElementCount < 3
heuristic. Keep focus selection scoped to that component so multiple paginations
and single-page configurations focus the interacted component’s aria-current
page.

In `@packages/pagination/test/index.test.tsx`:
- Around line 197-227: Make the “sets the focus after going to a new page” test
failure-safe by wrapping setup, assertions, and event dispatches in try/finally.
In the finally block, synchronously dispose the rendered root, remove the test
container from document.body, and restore HTMLElement.prototype.focus, ensuring
cleanup occurs even when an expectation throws.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: eeb323cd-bd54-4160-b350-8323d451bf09

📥 Commits

Reviewing files that changed from the base of the PR and between 7d01fb0 and 2f8405f.

📒 Files selected for processing (6)
  • .changeset/bright-tigers-switch.md
  • .storybook/ui/controls.tsx
  • packages/i18n/src/index.ts
  • packages/pagination/src/index.ts
  • packages/pagination/stories/pagination.stories.tsx
  • packages/pagination/test/index.test.tsx

Comment thread .storybook/ui/controls.tsx
Comment thread packages/pagination/src/index.ts
Comment thread packages/pagination/test/index.test.tsx
@davedbase

Copy link
Copy Markdown
Member

@atk before I merge do you want to address the CR comments? I think the changes are fine aside from that.

@atk atk force-pushed the fix/pagination-keyboard-controls branch from c634cd4 to cf83ad1 Compare July 13, 2026 09:21
@atk

atk commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

@atk before I merge do you want to address the CR comments? I think the changes are fine aside from that.

Done. There's still an unrelated test failing, but otherwise this is ready to merge.

@davedbase davedbase merged commit a0aac29 into next Jul 13, 2026
2 of 4 checks passed
@davedbase davedbase deleted the fix/pagination-keyboard-controls branch July 13, 2026 12:53
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