Skip to content

fix: UAP buttons misplaced when drawer opens via keyboard#4238

Merged
Who-is-PS merged 6 commits intomainfrom
dev-v3-philosr-uap-button
Feb 13, 2026
Merged

fix: UAP buttons misplaced when drawer opens via keyboard#4238
Who-is-PS merged 6 commits intomainfrom
dev-v3-philosr-uap-button

Conversation

@Who-is-PS
Copy link
Member

Description

UAP buttons appeared in wrong position when opening drawer via keyboard navigation. Position was calculated during CSS transition before it settled.

Changed to continuous position monitoring while buttons are visible, matching the existing PortalOverlay pattern.

Related links, issue #, if available: AWSUI-61721

How has this been tested?

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 Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.19%. Comparing base (8eeade2) to head (588c5ea).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4238   +/-   ##
=======================================
  Coverage   97.19%   97.19%           
=======================================
  Files         886      886           
  Lines       26008    26030   +22     
  Branches     9421     9435   +14     
=======================================
+ Hits        25278    25300   +22     
+ Misses        724      683   -41     
- Partials        6       47   +41     

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

@Who-is-PS Who-is-PS marked this pull request as ready for review February 11, 2026 15:33
@Who-is-PS Who-is-PS requested a review from a team as a code owner February 11, 2026 15:33
@Who-is-PS Who-is-PS requested review from jperals and removed request for a team February 11, 2026 15:33
jperals
jperals previously approved these changes Feb 12, 2026
return;
}

let cleanedUp = false;
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 code ever run? It's in the same function scope, so once the useEffect cleans up, this variable is already out of scope

Copy link
Member

Choose a reason for hiding this comment

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

My understanding is that since checkPosition is called with requestAnimationFrame, there is a non-zero chance that the component unmounted in-between —that is what cleanedUp tracks.

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 cleanedUp variable is captured by closure in both the checkPosition function and the cleanup function. When cleanup runs and sets cleanedUp = true, the pending rAF callback still has access to it via closure and will see the updated value, causing it to exit.

requestAnimationFrame(checkPosition);

return () => {
cleanedUp = true;
Copy link
Member

Choose a reason for hiding this comment

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

why do we introduce cleanedUp flag instead of cancelling the requested animation frames?

Copy link
Member Author

Choose a reason for hiding this comment

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

Valid point, I will update it with cancelAnimationFrame. It is cleaner

Copy link
Member

@pan-kot pan-kot left a comment

Choose a reason for hiding this comment

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

I see that a mock for requestAnimationFrame is added - but where is the test to ensure that the position is recomputed on every animation frame?

pan-kot
pan-kot previously approved these changes Feb 13, 2026
});

// Store RAF callbacks globally so flush() can be used in tests
let rafCallbacks: Set<FrameRequestCallback>;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: could these be consts?

Copy link
Member Author

Choose a reason for hiding this comment

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

Refactored it to const.

rafCallbacks = new Set<FrameRequestCallback>();
flushAnimationFrames = () => {
act(() => {
const callbacks = [...rafCallbacks]; // Snapshot before clearing
Copy link
Member

Choose a reason for hiding this comment

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

Why assign to a snapshot instead of just calling the callbacks first and clearing rafCallbacks afterwards?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because callbacks re-register themselves (animation loop). If we clear after executing, the newly registered callback is lost.

@jperals
Copy link
Member

jperals commented Feb 13, 2026

I see that a mock for requestAnimationFrame is added - but where is the test to ensure that the position is recomputed on every animation frame?

I see that a unit test for this has now been added, I'm OK with it but think that visual regression test is better here —testing the actual result and not depending so much on implementation details.

@Who-is-PS Who-is-PS requested a review from jperals February 13, 2026 09:06
@Who-is-PS Who-is-PS added this pull request to the merge queue Feb 13, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 13, 2026
@Who-is-PS Who-is-PS added this pull request to the merge queue Feb 13, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 13, 2026
@Who-is-PS Who-is-PS added this pull request to the merge queue Feb 13, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 13, 2026
@Who-is-PS Who-is-PS added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit 8c20e1c Feb 13, 2026
50 checks passed
@Who-is-PS Who-is-PS deleted the dev-v3-philosr-uap-button branch February 13, 2026 19:04
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.

4 participants