8000 fix(BPagination): right/left/up/down arrow keys now operating better … by rgeerts · Pull Request #2665 · bootstrap-vue-next/bootstrap-vue-next · GitHub
[go: up one dir, main page]

Skip to content

fix(BPagination): right/left/up/down arrow keys now operating better … #2665

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

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

rgeerts
Copy link
Contributor
@rgeerts rgeerts commented Apr 21, 2025

…after new page chosen

Describe the PR

This pull request attempts to fix the right/left/up/down arrow key behavior

Small replication

Go to https://bootstrap-vue-next.github.io/bootstrap-vue-next/docs/components/pagination.html#button-content

on the first pagination component click "4". now try to navigate using the keyboard with arrow "right". The expected behavior would be the focus would go to "5" it stays on "4".

now click on "5" and try arrow "left". You would expect to navigate to "4" but it stays on "5"

Another issue is if the currently active navigation is 2 and you navigate with "<<" or "<". Focus is lost whereas I think it makes best sense for navigation to be on "1". same idea for ">" and ">>" if on next to last.

PR checklist

What kind of change does this PR introduce? (check at least one)

  • Bugfix 🐛 - fix(...)
  • Feature - feat(...)
  • [ x] ARIA accessibility - fix(...)
  • Documentation update - docs(...)
  • Other (please describe)

The PR fulfills these requirements:

  • [ x] Pull request title and all commits follow the Conventional Commits convention or has an override in this pull request body This is very important, as the CHANGELOG is generated from these messages, and determines the next version type. Pull requests that do not follow conventional commits or do not have an override will be denied

Summary by CodeRabbit

  • New Features
    • Improved keyboard navigation for pagination, including better focus management when changing pages.
  • Bug Fixes
    • Enhanced ordering and filtering of pagination buttons to ensure correct focus behavior.
  • Tests
    • Added tests to verify keyboard navigation between pagination buttons using arrow keys.

Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
coderabbitai bot commented Apr 21, 2025

Walkthrough

The changes introduce improvements to the pagination component's button ordering and focus management. The template now assigns an explicit index to each page's <li> element, which is used to sort and filter button elements for accurate focus handling. The getButtons function is refactored to ensure only visible, correctly ordered buttons are considered. Focus behavior is enhanced so that, after changing pages, focus is set to the first or last button when navigating to the first or last page, respectively. Additionally, a new test verifies keyboard navigation across pagination buttons using arrow keys.

Changes

File(s) Change Summary
packages/bootstrap-vue-next/src/components/BPagination/BPagination.vue Refactored button ordering and filtering logic; added explicit index for each page; improved focus management after page changes; minor whitespace cleanups.
packages/bootstrap-vue-next/src/components/BPagination/pagination.spec.ts Added a test for keyboard navigation to verify focus movement between page buttons using arrow keys.

Poem

In the garden of pages, buttons now align,
With indices clear, their order’s divine.
Focus hops neatly from first to the last,
Keyboard and pointer—both moving fast!
Tests keep it tidy, navigation in view—
A hop, a skip, and a bug bid adieu!
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information o 10000 n how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
pkg-pr-new bot commented Apr 21, 2025

bsvn-vite-ts

npm i https://pkg.pr.new/bootstrap-vue-next/bootstrap-vue-next@2665
npm i https://pkg.pr.new/bootstrap-vue-next/bootstrap-vue-next/@bootstrap-vue-next/nuxt@2665

commit: 71c292c

Copy link
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/bootstrap-vue-next/src/components/BPagination/BPagination.vue (1)

347-364: Robust button sorting and filtering implementation

This refactored getButtons function addresses several issues:

  1. Properly sorts elements based on the newly added displayIndex attribute
  2. Correctly filters for only visible button elements
  3. Adds proper type casting for better type safety

One minor concern:

The line return true || !!(bcr && bcr.height > 0 && bcr.width > 0) has a redundant check since true || will always evaluate to true. Consider removing the bounding client rectangle check entirely or using it properly:

-      return true || !!(bcr && bcr.height > 0 && bcr.width > 0)
+      return true // If we don't need the BCR check anymore

Or if you want to keep the check:

-      return true || !!(bcr && bcr.height > 0 && bcr.width > 0)
+      return !!(bcr && bcr.height > 0 && bcr.width > 0)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62a9939 and 71c292c.

📒 Files selected for processing (2)
  • packages/bootstrap-vue-next/src/components/BPagination/BPagination.vue (3 hunks)
  • packages/bootstrap-vue-next/src/components/BPagination/pagination.spec.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (3)
packages/bootstrap-vue-next/src/components/BPagination/BPagination.vue (2)

10-15: Adding displayIndex improves keyboard navigation

The addition of the displayIndex attribute to each pagination item is a good approach. This explicit indexing enables proper sorting of button elements, which is crucial for keyboard navigation.


323-329: Improved focus management on first/last page navigation

This change properly handles focus when navigating to the first or last page, fixing a key accessibility issue. The replaced commented-out code wasn't working correctly, and this implementation is more straightforward.

packages/bootstrap-vue-next/src/components/BPagination/pagination.spec.ts (1)

469-487: Comprehensive test for keyboard navigation

Excellent addition of a test case that verifies the core keyboard navigation functionality. This test:

  1. Properly tests right arrow key navigation across multiple pages
  2. Verifies that clicking a page button and then continuing keyboard navigation works correctly
  3. Checks left arrow navigation functionality
  4. Validates the fixes for the issues described in the PR

The test is well-structured and covers all the key scenarios mentioned in the PR objectives.

@VividLemon VividLemon merged commit 2f05c84 into bootstrap-vue-next:main Apr 22, 2025
5 checks passed
@github-actions github-actions bot mentioned this pull request Apr 22, 2025
xvaara added a commit to xvaara/bootstrap-vue-next that referenced this pull request Apr 28, 2025
* upstream/main: (184 commits)
  fix(BDropdown): don't calulcate the position when dropdown is not shown.
  docs(BTable): complete documentation for table items provider (bootstrap-vue-next#2662)
  fix(BPagination): right/left/up/down arrow keys now operating better after new page chosen (bootstrap-vue-next#2665)
  add the check to hide as well
  fix(useShowHide): don't run show if component already unmounted (ie. BPopover)
  fix(BAccordionItem): fix initial modelValue
  feat(BModal)!: remove autofocus and autofocusButton props and add more versitile focus prop feat(BOffcanvas)!: remove nofocus prop and add more versitile focus prop feat(BModal): return focus to previous element on close feat(BOffcanvas): return focus to previous element on close fix(BModal): set focus only once
  chore: release main (bootstrap-vue-next#2659)
  bth and btd scope attribute updates and bpagination li element needs presentation role (bootstrap-vue-next#2646)
  feat(BBreadcrumb): allow it to use individual breadcrumb trails with useBreadcrumb by passing prop id to component and id param to composable fixes bootstrap-vue-next#2630
  Revert "fix(BButton): Consume useColorVariantClasses (bootstrap-vue-next#2640)" (bootstrap-vue-next#2654)
  chore: release main fixes bootstrap-vue-next#2643
  feat(BTable): Expose additional functions and document them (bootstrap-vue-next#2632)
  fix(BButton): Consume useColorVariantClasses (bootstrap-vue-next#2640)
  docs(BButton): Outline variant example (bootstrap-vue-next#2639)
  fix(BTab): error in recursion (bootstrap-vue-next#2624)
  fix(BTable): correct multi-sort to not update sortby in place (bootstrap-vue-next#2644)
  Update BDropdownForm.vue (bootstrap-vue-next#2635)
  doc(BTable): Fill out light-weight, helper component and accessibility sections (bootstrap-vue-next#2629)
  chore: release main (bootstrap-vue-next#2626)
  ...
VividLemon pushed a commit that referenced this pull request Apr 30, 2025
@github-actions github-actions bot mentioned this pull request May 5, 2025
xvaara added a commit to xvaara/bootstrap-vue-next that referenced this pull request May 14, 2025
* upstream/main:
  chore: release main (bootstrap-vue-next#2690)
  docs(BProgress): Parity pass (bootstrap-vue-next#2689)
  fix(BTableSimple): fixed and nobordercollapse to work fixes bootstrap-vue-next#2685
  docs: fix incorrect references and missed script sections (bootstrap-vue-next#2686)
  docs: implement on this page expand/collapse with useScrollspy (bootstrap-vue-next#2679)
  chore: release main (bootstrap-vue-next#2683)
  feat(BTable): implement 'fixed' and 'noBorderCollapse' props (bootstrap-vue-next#2681)
  chore: release main (bootstrap-vue-next#2678)
  Update package.json
  fix(BFormSelect): prevent options with label from being treated as groups (bootstrap-vue-next#2666)
  fix: patch regression issue in bootstrap-vue-next#2665 (bootstrap-vue-next#2670)
  Update release-main.yaml
  chore: release main (bootstrap-vue-next#2660)
  chore: update depencies
  fix(BTabs): corrent classes on ssr (bootstrap-vue-next#2664)
  Changes to public composables (bootstrap-vue-next#2425)
  docs(BTable): parity pass (bootstrap-vue-next#2669)
xvaara pushed a commit to unstoppablecarl/bootstrap-vue-next that referenced this pull request May 22, 2025
xvaara added a commit to unstoppablecarl/bootstrap-vue-next that referenced this pull request May 22, 2025
commit 2a9e30b
Author: Jukka Raimovaara <roska@mentalhouse.fi>
Date:   Thu May 15 18:24:07 2025 +0300

    doc data

commit 08c89fd
Author: Jukka Raimovaara <roska@mentalhouse.fi>
Date:   Thu May 15 17:57:29 2025 +0300

    feat(BPopover): add titleClass and bodyClass, remove unneeded customClass prop since class is inherited to the same place

commit 90b578d
Author: Jukka Raimovaara <roska@mentalhouse.fi>
Date:   Wed May 14 11:39:42 2025 +0300

    feat(BToast): add noProgress prop, make progress show as default if modelValue is number. fix(useToastController): if using the deprecated show method the countdown didn't start.

commit dc85d94
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Sun May 11 09:53:25 2025 -0500

    chore: release main (bootstrap-vue-next#2690)

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

commit 070cb8c
Author: David W. Gray <dwgray67@hotmail.com>
Date:   Sun May 11 07:52:30 2025 -0700

    docs(BProgress): Parity pass (bootstrap-vue-next#2689)

commit c61f532
Author: Thierry Blind <tbl0605@gmail.com>
Date:   Sun May 11 16:52:14 2025 +0200

    fix(BTableSimple): fixed and nobordercollapse to work fixes bootstrap-vue-next#2685

commit beae36f
Author: David W. Gray <dwgray67@hotmail.com>
Date:   Sun May 11 07:43:58 2025 -0700

    docs: fix incorrect references and missed script sections (bootstrap-vue-next#2686)

commit 34432d9
Author: David W. Gray <dwgray67@hotmail.com>
Date:   Sun May 11 07:42:02 2025 -0700

    docs: implement on this page expand/collapse with useScrollspy (bootstrap-vue-next#2679)

commit ce869f0
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Wed May 7 11:16:08 2025 -0500

    chore: release main (bootstrap-vue-next#2683)

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

commit 9486276
Author: Mohamed Nasri <51300752+mhn147@users.noreply.github.com>
Date:   Wed May 7 09:44:38 2025 -0600

    feat(BTable): implement 'fixed' and 'noBorderCollapse' props (bootstrap-vue-next#2681)

commit a4a9294
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Mon May 5 09:16:09 2025 -0500

    chore: release main (bootstrap-vue-next#2678)

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

commit 0165e94
Author: Jukka Raimovaara <roska@mentalhouse.fi>
Date:   Mon May 5 16:24:04 2025 +0300

    Update package.json

commit c1645a9
Author: Rajitha <rajithaeye@gmail.com>
Date:   Wed Apr 30 23:49:23 2025 +0530

    fix(BFormSelect): prevent options with label from being treated as groups (bootstrap-vue-next#2666)

commit 59ddc39
Author: Thierry Blind <tbl0605@gmail.com>
Date:   Wed Apr 30 20:17:34 2025 +0200

    fix: patch regression issue in bootstrap-vue-next#2665 (bootstrap-vue-next#2670)

commit d82091b
Author: Jukka Raimovaara <roska@mentalhouse.fi>
Date:   Wed Apr 30 06:01:10 2025 +0300

    Update release-main.yaml

commit 31cb4bf
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Wed Apr 30 04:51:31 2025 +0300

    chore: release main (bootstrap-vue-next#2660)

    Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

commit 6733770
Author: Jukka Raimovaara <roska@mentalhouse.fi>
Date:   Wed Apr 30 05:15:02 2025 +0300

    chore: update depencies

commit 2b37c18
Author: Jukka Raimovaara <roska@mentalhouse.fi>
Date:   Wed Apr 30 04:36:46 2025 +0300

    fix(BTabs): corrent classes on ssr (bootstrap-vue-next#2664)

    fix(BTabs): corrent classes on ssr
    fix(BTabs): fix another recursion error

commit 99718eb
Author: Jukka Raimovaara <roska@mentalhouse.fi>
Date:   Wed Apr 30 04:20:00 2025 +0300

    Changes to public composables (bootstrap-vue-next#2425)

    feat(BAlert)!: make act like toast, useShowHide.
    feat(useShowHide): create triggerRegistry for adding external triggers (like in vBToggle)
    fix: type popoverController
    fix(useShowHide): focustrap off at the begining of leave, pass down the trigger to other hide emits.
    fix(vBToggle): keep track of targets
    fix(BPopover)!: change prop content to body to align with other components
    fix(BTooltip)!: change prop content to body to align with other components
    feat(usePopoverController): allow more options
    fix(vBToggle): find late components, ie. inside ClientOnly
    fix(useModalController)!: move props to main level, add slots
    feat(usePopoverController): add slots
    feat(useToastController)!: remove props obj, the parameters are flat now. Add slots, rename pos -> position
    feat(useShowHide): show returns a promise, resolve on show or hide.
    feat(useToggle): toggle any show/hide component
    feat!: controller composables functions return promise, with chainable functions
    feat(useModalController): add support for using syntax in ts
    feat(BModal): add okClass and cancelClass to add classes to the buttons.
    feat(useModalController)!: change of api, check the docs
    fix: inline functional style to show toast,modal and dropdown
    feat(useToggle): add trigger to promise resolve on hide.
    fix(BCarousel): fix v-for updates

commit 340edfd
Author: David W. Gray <dwgray67@hotmail.com>
Date:   Mon Apr 28 18:39:44 2025 -0700

    docs(BTable): parity pass (bootstrap-vue-next#2669)

commit 4dd6c89
Author: Jukka Raimovaara <roska@mentalhouse.fi>
Date:   Mon Apr 28 22:46:31 2025 +0300

    fix(BDropdown): don't calulcate the position when dropdown is not shown.
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
0