Skip to content

fix: href in ActionListLinkItem not working inside TopBar+ActionMenu#2256

Open
chornonoh-vova wants to merge 3 commits intodevelopfrom
fix/href-in-link-not-working-inside-action-menu
Open

fix: href in ActionListLinkItem not working inside TopBar+ActionMenu#2256
chornonoh-vova wants to merge 3 commits intodevelopfrom
fix/href-in-link-not-working-inside-action-menu

Conversation

@chornonoh-vova
Copy link
Contributor

@chornonoh-vova chornonoh-vova commented Feb 24, 2026

Fix: Action menu links not navigating when clicked

Problem

ActionListLinkItem elements inside an ActionMenu were not navigating to their href when clicked. The onBlur handler added to AnchoredOverlay would fire before the click event could complete, closing the menu and removing the link from the DOM.

Solution

Updated handleOverlayBlur to check event.relatedTarget before deciding whether to close the menu:

  • Focus moves to the trigger — return early and let handleTriggerClick handle closing, preventing a double-close that was causing the menu to re-open and navigate to the first link
  • Focus moves inside the overlay — return early so link clicks can complete before the menu closes
  • Focus moves anywhere else — close the menu as normal (tabbing out, clicking outside, etc.)

Testing

Added two new tests to cover the affected scenarios:

  • Verifies that clicking an ActionListLinkItem navigates to the correct href
  • Verifies that the menu closes when focus moves outside the overlay (via tab)

Copilot AI review requested due to automatic review settings February 24, 2026 15:53
@chornonoh-vova chornonoh-vova requested a review from a team as a code owner February 24, 2026 15:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where href attributes in ActionListLinkItem components were not working when used inside a TopBar+ActionMenu pattern. The issue was that the menu would close prematurely when clicking a link, preventing navigation.

Changes:

  • Enhanced blur event handling in ActionMenu to prevent premature closing when clicking links
  • Added comprehensive test coverage for link navigation and focus management
  • Included test cleanup to prevent test pollution

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/react/src/components/ActionMenu/ActionMenu.tsx Modified handleOverlayBlur to check if focus remains within the overlay or moves to the trigger before closing the menu
packages/react/src/components/ActionMenu/ActionMenu.test.tsx Added afterEach cleanup for window.location.hash and two new tests verifying link navigation and focus behavior
packages/react/src/components/ActionList/ActionListItem.tsx Formatting-only change breaking the interface declaration across multiple lines

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aws-amplify-us-east-1
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-2256.d15792l1n26ww3.amplifyapp.com

@chornonoh-vova chornonoh-vova enabled auto-merge (squash) February 27, 2026 11:16
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