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 FilterSelect jumping issue #5477

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

mcwinter07
Copy link
Contributor

@mcwinter07 mcwinter07 commented Jan 20, 2025

Why

This is a second (third?) attempt at resolving the Select / FilterSelect jump issue.

Steps to replicate (prior to this fix)

In chrome

  1. Go to a page with the FilterSelect that does not have a selected value (see a somewhat janky example with the stickersheets here)
  2. use keyboard navigation to open the FilterSelect
  3. The view should jump up to the top of the page

Why we think this happens

This component is composed of many primitive that seek to control focus management. The suspected culprit is the React Aria listbox keyboard behavior.

We've had to try a co-opt its focus management manually but due to how it renders, seemingly its start position is above the page, causing the jump on focus.

Screenshot 2025-01-20 at 11 07 20 AM

What

I've introduced a hook that checks for a stable y position that should ensure that the focus resolve after it is a single value

Copy link

changeset-bot bot commented Jan 20, 2025

🦋 Changeset detected

Latest commit: e20b8b0

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

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

@mcwinter07 mcwinter07 changed the title Fix filterSelect jumping issue Fix FilterSelect jumping issue Jan 20, 2025
@mcwinter07
Copy link
Contributor Author

Validated this would in survey-reporting-ui with the canary 0.0.0-canary-fix-filter-select-jump-issue-useHasStableYPosition-20250120225815, will check with the two teams that reported this to see if it works ok for them

@mcwinter07 mcwinter07 force-pushed the KZN-2885/filter-select-jumping-issue branch from 3bbc720 to 5b56c59 Compare January 23, 2025 05:08
@mcwinter07 mcwinter07 force-pushed the KZN-2885/filter-select-jumping-issue branch from 5b56c59 to 426898d Compare January 23, 2025 05:15
@mcwinter07 mcwinter07 marked this pull request as ready for review January 23, 2025 05:40
@mcwinter07 mcwinter07 requested a review from a team as a code owner January 23, 2025 05:40
@mcwinter07 mcwinter07 force-pushed the KZN-2885/filter-select-jumping-issue branch from ae09c1f to 426898d Compare January 23, 2025 23:06
Copy link
Contributor

github-actions bot commented Jan 23, 2025

✨ Here is your branch preview! ✨

Last updated for commit e20b8b0: update useHasCalculatedListboxPosition hook to reduce the number of intervals

if (lastYPosition === null) {
setLastYPosition(y)
} else if (y === lastYPosition && y >= 0) {
setIsStable(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense, and is possible to clear the interval here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice spot on this, the interval was re-running constantly while the popover was open. I've updated the interval to call itself only while is position is not stable, so we're going from this:

Screenshot 2025-01-30 at 9 17 39 am

To this:
Screenshot 2025-01-30 at 9 29 34 am

@mcwinter07 mcwinter07 requested a review from dougmacknz January 29, 2025 22:43
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