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(COMPONENT): Unexpected Behavior with Number Input and MatTooltip Scrolling #29074

Closed
1 task
armellarcier opened this issue May 20, 2024 · 2 comments · Fixed by #29449
Closed
1 task

bug(COMPONENT): Unexpected Behavior with Number Input and MatTooltip Scrolling #29074

armellarcier opened this issue May 20, 2024 · 2 comments · Fixed by #29449
Labels
area: material/tooltip P4 A relatively minor issue that is not relevant to core functions

Comments

@armellarcier
Copy link

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

In Angular Material, when a with matInput is used, the expected behavior is that scrolling over this input field scrolls the page. However, if I hover over any element with MatTooltip, then focus back on the number input field, the scrolling behavior unexpectedly changes. Instead of scrolling the page, it increments or decrements the number in the input. This issue can also occur on the Angular Material official website.

image

This is not the expected behavior : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number

Reproduction

StackBlitz link: https://stackblitz.com/angular/porobbapdry?file=src%2Fapp%2Ftooltip-delay-example.ts
Steps to reproduce:

  1. Navigate to a page with a with matInput.
  2. Hover over an element with MatTooltip.
  3. Focus on the number input field.
  4. Try scrolling over the number input field.

Expected Behavior

The expected and consistent user experience is that scrolling over a number input field should scroll the page, not change the input's value. This unexpected behavior disrupts the user experience, especially in forms with tooltips and number inputs.

Actual Behavior

When a field with matInput is focused, and the user scrolls with the mouse wheel, the default behavior is for the page itself to scroll, not the number in the input field. However, this behavior changes after interacting with an element that has MatTooltip. Specifically, after hovering over a MatTooltip element and then focusing on the number input field, scrolling with the mouse wheel no longer scrolls the page. Instead, it changes the value in the number input field, incrementing or decrementing it. This is inconsistent with the expected behavior and occurs even on the Angular Material official website.

Environment

  • Angular: 16
  • CDK/Material: 16
  • Browser(s): Chrome
  • Operating System Windows + macOS + ArchLinux
@armellarcier armellarcier added the needs triage This issue needs to be triaged by the team label May 20, 2024
@crisbeto crisbeto added P4 A relatively minor issue that is not relevant to core functions area: material/tooltip and removed needs triage This issue needs to be triaged by the team labels May 22, 2024
@ChristophWieske
Copy link
Contributor

ChristophWieske commented Jul 3, 2024

The issue comes from the wheel event that the tooltip uses to get a proper trigger to hide again. However there is an issue with the wheel event in chromium: https://issues.chromium.org/issues/334994023

Test it yourself: https://stackblitz.com/edit/stackblitz-starters-yjt7dn?file=index.html

Last info from the chromium team was: Won´t Fix.

I think removing the wheel handler after the tooltip hid could reduce the impact of the issue. However the user would still experience the changed behavior while the toolip is open (due to delay or when it is attached directly to the input)

We could add a wheel handler on matInput[type=number] per default
--> The behavior would consistently stay increment/decrement

If that is a suitable solution I would prepare a pull request for that. Is it a suitable solution?

(Firefox always shows increment/decrement behavior)

ChristophWieske added a commit to ChristophWieske/components that referenced this issue Jul 17, 2024
In blink and webkit browsers the default behavior of increasing or decreasing a focused number input on wheel events is broken until a wheel event listener is explicitly added.

Fixes angular#29074
ChristophWieske added a commit to ChristophWieske/components that referenced this issue Jul 19, 2024
In blink and webkit browsers the default behavior of increasing or decreasing a focused number input on wheel events is broken until a wheel event listener is explicitly added.

Fixes angular#29074
ChristophWieske added a commit to ChristophWieske/components that referenced this issue Jul 19, 2024
In blink and webkit browsers the default behavior of increasing or decreasing a focused number input on wheel events is broken until a wheel event listener is explicitly added.

Fixes angular#29074
ChristophWieske added a commit to ChristophWieske/components that referenced this issue Jul 19, 2024
In blink and webkit browsers the default behavior of increasing or decreasing a focused number input on wheel events is broken until a wheel event listener is explicitly added.

Fixes angular#29074
ChristophWieske added a commit to ChristophWieske/components that referenced this issue Jul 19, 2024
In blink and webkit browsers the default behavior of increasing or decreasing a focused number input on wheel events is broken until a wheel event listener is explicitly added.

Fixes angular#29074
crisbeto pushed a commit that referenced this issue Jul 19, 2024
…29449)

In blink and webkit browsers the default behavior of increasing or decreasing a focused number input on wheel events is broken until a wheel event listener is explicitly added.

Fixes #29074

(cherry picked from commit 10da6c6)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/tooltip P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants