demarches-normaliennes/app/javascript/controllers/number_input_controller.ts
2023-03-01 11:11:37 +01:00

16 lines
442 B
TypeScript

import { isInputElement } from '@coldwired/utils';
import { ApplicationController } from './application_controller';
export class NumberInputController extends ApplicationController {
connect() {
this.onGlobal('wheel', (event) => {
if (
isInputElement(event.target) &&
event.target.type == 'number' &&
document.activeElement == event.target
) {
event.preventDefault();
}
});
}
}