Skip to content

Commit 9602593

Browse files
committed
fix: wheel over a focused number input scrolls the page instead of silently changing the value, the input loses focus first AdminForth/2005
1 parent f32ab5f commit 9602593

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎adminforth/spa/src/main.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ app.use(router)
1818
// get access to i18n instance outside components
1919
initI18n(app);
2020

21+
// Chrome steps a focused number input on wheel, so scrolling the page with the cursor over the field
22+
// silently changes a price or amount; blurring it first lets the page scroll and keeps the value
23+
document.addEventListener('wheel', (e) => {
24+
if (e.target instanceof HTMLInputElement && e.target.type === 'number' && e.target === document.activeElement) {
25+
e.target.blur();
26+
}
27+
}, { passive: true });
28+
2129

2230
/* IMPORTANT:ADMINFORTH CUSTOM USES */
2331

0 commit comments

Comments
 (0)