Skip to content

fix(ActionMenu): correct action menu scrolling on open#2248

Open
Bracciata wants to merge 10 commits intodevelopfrom
fix/correct-action-menu-scrolling-on-open
Open

fix(ActionMenu): correct action menu scrolling on open#2248
Bracciata wants to merge 10 commits intodevelopfrom
fix/correct-action-menu-scrolling-on-open

Conversation

@Bracciata
Copy link
Contributor

@Bracciata Bracciata commented Feb 11, 2026

Closes https://github.com/dequelabs/walnut/issues/13307

This fix prevents a bug where when there was a large list of ActionMenus in one container on first open it may scroll to the top of the page.

This bug be reproduced by reverting the changes in this pr and scrolling down to the bottom of a page rendered with this MDX

function ScrollPreservedExample() {
  const projects = [
    { id: '1', name: 'Project One', lastRun: '2 hours ago' },
    { id: '2', name: 'Project Two', lastRun: '1 day ago' },
    { id: '3', name: 'Project Three', lastRun: '3 days ago' },
    { id: '4', name: 'Project Four', lastRun: '1 week ago' },
    { id: '5', name: 'Project Five', lastRun: '2 weeks ago' },
    { id: '6', name: 'Project Six', lastRun: '3 weeks ago' },
    { id: '7', name: 'Project Seven', lastRun: '1 month ago' },
    { id: '8', name: 'Project Eight', lastRun: '2 months ago' },
    { id: '9', name: 'Project Nine', lastRun: '3 months ago' },
    { id: '10', name: 'Project Ten', lastRun: 'Never' },
  ];
  return (
    <div style={{ padding: '0 1rem', minHeight: '200vh' }}>
      <div style={{ marginBottom: '2rem' }}>
        <strong>Scroll down to a row near the bottom, then open Settings.</strong> If the bug is present, the page may jump.
      </div>
      <Panel>
        <Table>
          <TableHead>
            <TableRow>
              <TableHeader scope="col">Project Name</TableHeader>
              <TableHeader scope="col">Last Run</TableHeader>
              <TableHeader scope="col">Actions</TableHeader>
            </TableRow>
          </TableHead>
          <TableBody>
            {projects.map((project) => (
              <TableRow key={project.id}>
                <TableHeader scope="row" variant="cell">
                  {project.name}
                </TableHeader>
                <TableCell>{project.lastRun}</TableCell>
                <TableCell>
                  <div style={{ display: 'flex', gap: '8px', alignItems: 'center' }}>
                    <Link href={`#project-${project.id}`}>Open project</Link>
                    <ActionMenu
                      trigger={
                        <Button
                          variant="secondary"
                          aria-label={`Settings for ${project.name}`}
                        >
                          <Icon type="gears" />
                          Settings
                          <Icon type="chevron-down" />
                        </Button>
                      }
                    >
                      <ActionList>
                        <ActionListLinkItem href={`#configure-${project.id}`}>
                          Configure project
                        </ActionListLinkItem>
                        <ActionListLinkItem href={`#members-${project.id}`}>
                          Members
                        </ActionListLinkItem>
                      </ActionList>
                    </ActionMenu>
                  </div>
                </TableCell>
              </TableRow>
            ))}
          </TableBody>
        </Table>
      </Panel>
    </div>
  );
}`

Bracciata and others added 5 commits February 11, 2026 15:11
@Bracciata Bracciata marked this pull request as ready for review February 11, 2026 21:56
@Bracciata Bracciata requested a review from a team as a code owner February 11, 2026 21:56
Copilot AI review requested due to automatic review settings February 11, 2026 21:56
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

Fixes an ActionMenu open-time scroll jump by delaying focus until after layout has completed.

Changes:

  • Defers focusing the ActionMenu list via a double requestAnimationFrame when open becomes true.

💡 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-2248.d15792l1n26ww3.amplifyapp.com

Updated tests to wait for the ActionList to be focused after the double
requestAnimationFrame completes before interacting with keyboard events.
This ensures the async focus operation has completed before the tests
continue with keyboard interactions.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@Bracciata Bracciata requested a review from Zidious February 11, 2026 23:29
Copy link
Contributor

@Zidious Zidious left a comment

Choose a reason for hiding this comment

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

Left a comment inline -

I'll leave final 👀 to @anastasialanz - I'm not too familiar with requestAnimationFrame to give an educated opinion.

@Bracciata Bracciata enabled auto-merge (squash) February 24, 2026 18:07
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