Skip to content

Conversation

@pan-kot
Copy link
Member

@pan-kot pan-kot commented Aug 25, 2025

Description

Fixes a bug when auto-scrolling would not stop after transaction commits. Logically, when the transaction is submitted or discarded, the auto-scroll handlers should be removed, which is supposed to prevent the scroll. However, this does not happen due to a rather complex lifecycle involved. Removing unneeded React state and making the event listeners added and removed only once per component mount/unmount fixes the problem.

Before:

Screen.Recording.2025-08-25.at.18.15.39.mov

After:

Screen.Recording.2025-08-25.at.18.16.07.mov

Rel: AWSUI-61150, similar to: #368

How has this been tested?

  • New functional test for regression
  • New unit tests to cover the auto-scroll util
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 Aug 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.40%. Comparing base (8ff00c0) to head (b9c9f45).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #367      +/-   ##
==========================================
+ Coverage   94.98%   95.40%   +0.41%     
==========================================
  Files          67       67              
  Lines        3250     3263      +13     
  Branches      692      703      +11     
==========================================
+ Hits         3087     3113      +26     
+ Misses        163      150      -13     

☔ 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.

@pan-kot pan-kot marked this pull request as ready for review August 25, 2025 16:37
@pan-kot pan-kot requested a review from a team as a code owner August 25, 2025 16:37
@pan-kot pan-kot requested review from cansuaa and removed request for a team August 25, 2025 16:37
Comment on lines +57 to +59
document.activeElement.scrollIntoView?.({ behavior: "smooth", block: "nearest" });
}
this.scrollRepeat();
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't scrollIntoView already scroll? Why do we need this.scrollRepeat()?

If there is no activeElement in the document, where is this supposed to scroll?

Copy link
Member Author

Choose a reason for hiding this comment

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

The scrollRepeat repeatedly checks for the cursor position and if it is on edge - it will scroll automatically with small time increments.

The scheduleActiveElementScrollIntoView is an action which is called on-demand. To have no conflict with the repeated scroll, it reuses the same timeout reference. First, it clears the timeout which is normally set every 10ms by scroll repeat. Then, it performs its own scrolling after a delay. Finally, it has to restart the repeated auto-scroll, as otherwise it won't work anymore after scheduleActiveElementScrollIntoView() is called.

expect(scroll1.top).toBe(0);

// This should cancel the operation.
await page.mouseMove(0, 255);
Copy link
Member

Choose a reason for hiding this comment

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

Does this go beyond the window and cause scrolling?

Copy link
Member Author

Choose a reason for hiding this comment

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

This goes to the bottom edge of the window, which is enough. The auto-scrolling activates when the cursor is within 50px from either top or bottom screen edge.

@pan-kot pan-kot added this pull request to the merge queue Aug 26, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 26, 2025
@pan-kot pan-kot added this pull request to the merge queue Aug 26, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 26, 2025
@pan-kot pan-kot added this pull request to the merge queue Aug 26, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 26, 2025
@pan-kot pan-kot enabled auto-merge August 26, 2025 13:36
@pan-kot pan-kot added this pull request to the merge queue Aug 26, 2025
Merged via the queue into main with commit 5ba94ef Aug 26, 2025
69 of 70 checks passed
@pan-kot pan-kot deleted the fix-auto-scroll-release branch August 26, 2025 14:02
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