Skip to content

Conversation

@tgxworld
Copy link
Contributor

@tgxworld tgxworld commented Dec 16, 2025

Whenever the HorizontalOverflowNav component is rendered, we call
scrollIntoView on the current active element to ensure that the link
which is currently active will be shown to the user. However, we were
calling scrollIntoView with the container option defaulting to all
which impacts all scrollable containers.

Per mozilla docs,

All scrollable containers are impacted (including the viewport).

This is not ideal as it can cause unintended scrolls on the viewport thus resulting in a bad UX. To resolve this, this commit adds the container: "nearest" option when we call scrollIntoView which ensures that only the nearest scrollable container to the active element is impacted.

This problem was discovered while I was looking at review queue index
page and noticed that my scroll position was always lost when new
reviewable items are added to the page. It turns out that the review
queue index page renders the reviewable-refresh/item.gjs component
which then renders the horizontal-overflow-nav.gjs component.

Whenever the `HorizontalOverflowNav` component is rendered, we call the
`scrollIntoView` on the current active element to ensure that the link
which is currently active will be shown to the user. However, we were
calling `scrollIntoView` with the `container` option defaulting to `all`
which impacts all scrollable containers.

Per mozilla docs,

> All scrollable containers are impacted (including the viewport).

This is not ideal as it can cause unintended scrolls on the viewport
when there are other scrollable containers on the user's screen thus
resulting in a bad UX. To resolve this, this commit adds the `container:
"nearest"` option when we call `scrollIntoView` which ensures that only
the nearest scrollable container to the active element is impacted.

This problem was discovered while I was looking at review queue index
page and noticed that my scroll position was always lost when new
reviewable items are added to the page. It turns out that the review
queue index page renders the `reviewable-refresh/item.gjs` component
which then renders the `horizontal-overflow-nav.gjs` component.
@tgxworld
Copy link
Contributor Author

Reviewer notes

Before

scroll_before

After

scroll_after

activeElement?.scrollIntoView({
block: "nearest",
inline: "center",
container: "nearest",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tgxworld tgxworld merged commit 63fea13 into main Dec 16, 2025
18 of 19 checks passed
@tgxworld tgxworld deleted the fix_scrolling_on_review_queue_index-2 branch December 16, 2025 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants