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: scroll focused item to be first visible item after pagedown #7050

Merged
merged 4 commits into from
Jan 22, 2024

Conversation

bwajtr
Copy link
Contributor

@bwajtr bwajtr commented Jan 4, 2024

Description

Pressing PageDown (Fn + Arrow Down on MacBooks) in the Grid should do the following, according to the documentation:

Moves cell focus down by one page of visible rows

The current implementation does that correctly. However, the position of the newly focused item is sometimes at the bottom of the grid, and sometimes, it's the first item at the top of the grid. Besides the obvious inconsistency in behavior, it may also happen to you that you "skip" some items while scrolling the grid using PageDown. Notice that in the following video, you never see items 8 to 12, when pressing PageDown:

Zaznam.obrazovky.2024-01-04.v.18.02.00.mov

This PR changes PageDown behavior so the currently focused item is scrolled to the top of the grid, so it becomes the first visible item. Only then is the focus moved to the last fully visible item in the grid. This way, the user can be sure that none of the items were skipped.

Implementation note: Calling scrollToIndex(currentRowIndex) before counting the visible items makes PageDown work better when the grid has variable height rows.

Fixes vaadin/flow-components#5794

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/contributing/overview
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.
  • I have not completed some of the steps above and my pull request can be closed immediately.

@bwajtr bwajtr requested a review from tomivirkki January 19, 2024 13:52
Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@tomivirkki tomivirkki merged commit 4344876 into main Jan 22, 2024
9 checks passed
@tomivirkki tomivirkki deleted the fix/5794-page-down-on-a-grid branch January 22, 2024 09:03
tomivirkki pushed a commit that referenced this pull request Jan 22, 2024
tomivirkki pushed a commit that referenced this pull request Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Page down on a grid with filtering
3 participants