Commit 9607b4ac authored by Mathias Chouet's avatar Mathias Chouet :spaghetti:
Browse files

Restrict up/down key inhibition to number inputs only

Showing with 3 additions and 19 deletions
+3 -19
...@@ -716,27 +716,11 @@ export class AppComponent implements OnInit, OnDestroy, Observer { ...@@ -716,27 +716,11 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
} }
} }
/**
* Disable value modification on mouse wheel or up/down arrows, in input type="number"
*/
/* @HostListener("mousewheel", [ "$event" ]) onMouseWheelChrome(event: any) {
this.disableScroll(event);
}
@HostListener("DOMMouseScroll", [ "$event" ]) onMouseWheelFirefox(event: any) {
this.disableScroll(event);
}
@HostListener("onmousewheel", [ "$event" ]) onMouseWheelIE(event: any) {
this.disableScroll(event);
}
disableScroll(event: any) {
if (event.srcElement.type === "number") {
event.preventDefault();
// @TODO how to send event to parent (or Window ?) so that scrolling the page works ?
}
} */
@HostListener("keydown", [ "$event" ]) onKeydown(event: any) { @HostListener("keydown", [ "$event" ]) onKeydown(event: any) {
if (event.which === 38 || event.which === 40) { // up / down arrow if (event.which === 38 || event.which === 40) { // up / down arrow
event.preventDefault(); if (event.srcElement.type === "number") {
event.preventDefault();
}
} }
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment