-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix(material/input): Number input not changing on wheel interaction #29449
fix(material/input): Number input not changing on wheel interaction #29449
Conversation
Tried to add a test as well, but wasn´t able to trigger the inputs default wheel behavior with dispatched events. I assume it only works with trusted events. Added a section to the dev app that shows the scenario that triggered the issue (number input + tooltip). |
src/material/input/input.ts
Outdated
// For example: Hitting a tooltip once enables the mouse wheel input for all number inputs as long as it exists. | ||
// In order to get reliable and intuitive behavior we apply a wheel event on our own | ||
// thus making sure increment and decrement by mouse wheel works every time. | ||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this out into a private method since the setter is getting pretty big.
src/material/input/input.ts
Outdated
this._type === 'number' && | ||
(this._platform.BLINK || this._platform.WEBKIT) | ||
) { | ||
this._elementRef.nativeElement.addEventListener('wheel', this._WebkitBlinkWheelListener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we bind this outside the NgZone
?
src/material/input/input.ts
Outdated
@@ -527,4 +551,10 @@ export class MatInput | |||
el.setSelectionRange(0, 0); | |||
} | |||
}; | |||
|
|||
private _WebkitBlinkWheelListener = (): void => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming of this will likely trigger a lint warning.
5211989
to
6f3f32f
Compare
@crisbeto I applied your feedback and fixed linter errors. Have a look. |
@ChristophWieske you need to run |
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
6f3f32f
to
7c5a995
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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