Skip to content

Conversation

@mxschll
Copy link
Member

@mxschll mxschll commented Nov 21, 2025

Note: This PR supersedes PR#3943 and includes an additional fix. The original implementation used globalIndex for the position offset calculation, which caused whitespace issues when scrolling through large lists:

// ./src/select/utils/render-options.tsx
const adjustedVirtualPosition = virtualItem ? virtualItem.start - globalIndex : undefined;

Changed to use index (virtual window position) instead of globalIndex (absolute list position) to correctly calculate the 1px overlap offset:

// ./src/select/utils/render-options.tsx
const adjustedVirtualPosition = virtualItem ? virtualItem.start - index : undefined;

Description

With virtual scrolling enabled, selectable items would "jump" on hover/selection due to border width changes (AWSUI-61303). Virtual scrolling positions items absolutely, so when border width changes from 1px to 2px on hover, the browser recalculates layout dimensions causing visible position shifts.

Additionally, option groups were missing the separating top border.

Before After
6ab8eb377aa9c0 65b1c41442f210

The solution uses box-shadows when virtual scrolling is enabled to simulate thick borders while maintaining thin actual borders. An alternative solution of making all borders the same thickness (hover / non-hover) would change the visual appearance compared to how it's supposed to look.

In summary:

  • Eliminates jumping behavior with virtual scrolling enabled
  • Maintains visual consistency with non-virtual scrolling
  • Adds top separator to option groups

How has this been tested?

Changes ran through screenshot test and have been verified locally.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Nov 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.12%. Comparing base (b9e85f0) to head (68dbe3d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4064   +/-   ##
=======================================
  Coverage   97.12%   97.12%           
=======================================
  Files         864      864           
  Lines       25325    25327    +2     
  Branches     9137     9137           
=======================================
+ Hits        24597    24599    +2     
  Misses        722      722           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

fix: inconsistent dropdown styling with virtual scroll
refactor: deduplicate code
- Each item is shifted up by its index in pixels
- The layout strut height is reduced by the number of items to account for the cumulative overlap
Use virtual window index instead of global index when calculating position
offset. This prevents excessive whitespace when scrolling through large lists
with virtual scrolling enabled.
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.

1 participant