Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(CDK menu): Menu directive breaks scrollbar scrolling behavior #30130

Open
2 of 5 tasks
ptu14 opened this issue Dec 5, 2024 · 0 comments · May be fixed by #30249
Open
2 of 5 tasks

bug(CDK menu): Menu directive breaks scrollbar scrolling behavior #30130

ptu14 opened this issue Dec 5, 2024 · 0 comments · May be fixed by #30249
Assignees
Labels
area: cdk/menu P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@ptu14
Copy link

ptu14 commented Dec 5, 2024

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

When the @angular/cdk/menu directive is applied to a scrollable element, it causes scroll behavior abnormalities. Clicking in the empty space within the scrollable area causes the content to unexpectedly scroll to the top. Additionally, general mouse scrolling behavior becomes erratic and unpredictable.

Reproduction

StackBlitz link: https://stackblitz.com/edit/gwxbpu?file=src%2Fexample%2Fcdk-menu-inline-example.css,src%2Fexample%2Fcdk-menu-inline-example.html
Steps to reproduce:

  • 1. Create a scrollable container with some content that exceeds the container height
  • 2. Apply the @angular/cdk/menu directive to this container
  • 3. Try to scroll using the mouse:
  • 4. Click in the empty space within the scrollable area

video:
https://github.com/user-attachments/assets/1604a8f4-06b6-4bbf-809d-de0ecb2bb2f6

Expected Behavior

Clicking in empty space of the scrollbar should behave like natively, i.e. actually scroll down

Actual Behavior

Clicking in empty space within the scrollable area causes the content to immediately scroll to the top

Environment

  • Angular: 19.0.2
  • CDK/Material: 19.0.2
  • Browser(s): Chrome Version 131.0.6778.85 (Official Build) (arm64), Safari Version 18.1 (18619.2.8.111.5, 18619), Probably all browsers
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS, probably all systems
@ptu14 ptu14 added the needs triage This issue needs to be triaged by the team label Dec 5, 2024
@crisbeto crisbeto self-assigned this Dec 30, 2024
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: cdk/menu and removed needs triage This issue needs to be triaged by the team labels Dec 30, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 30, 2024
The CDK menu has some logic that forwards focus to the first item when the host is focused. The problem is that every time the user clicks on the scrollbar, they blur the current item and focus the menu which then forwards focus back to the first item which in turn causes the scroll position to jump to the top.

These changes add some logic to not forward focus when focus comes from a mouse interaction.

Fixes angular#30130.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/menu P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants