-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[TextField] How to prevent mousewheel in input of type number? #7960
Comments
@barbalex I'm not sure to follow. What's preventing you from implementing this behavior? I can't think of anything we are doing to block the behavior. You could try to reproduce the issue on a native I'm closing. Feel free to reopen if you can provide a reproduction example. codesandbox.io is a good place to start with. As a side note, we are bringing a number input: #19154. |
Hi. It's working with : <TextField type="number" onWheel={event => { event.preventDefault(); }} /> Hope it will helps. |
Both my general workaround and @Tomlgls do not seem to work any more in Chrome. When you implement them an error appears:
Linking to this page: https://www.chromestatus.com/features/6662647093133312 I have absolutely no idea why this would happen when you specifically add an onWheel event listener directly on the Input. But that is what happens. Just to explain why this is important: When users enter a value in a number field and then scroll the window, they inadvertently change the value they just have set. This is horrible UX and that is why I keep getting error reports about this "feature" that unfortunately is standard behavior. Also: The window does not scroll (but that is a lesser concern). It obviously has nothing to do with material-ui but fact is that I have to somehow prevent this when using material-ui. The issue is visible on the material-ui demo page. I have also prepared a demo that also shows that the onWheel does not prevent it from happening any more: https://codesandbox.io/s/material-demo-wdgpg?fontsize=14. Instructions to reproduce the basic effect:
Instructions to reproduce that an onWheel event handler cannot prevent this:
|
@barbalex I will confess I haven't looked at this problem in depth, but you can get around the passive event error by attaching it to a import React from "react";
import clsx from "clsx";
import { makeStyles } from "@material-ui/core/styles";
import MenuItem from "@material-ui/core/MenuItem";
import TextField from "@material-ui/core/TextField";
const useStyles = makeStyles(theme => ({
container: {
display: "flex",
flexWrap: "wrap"
},
textField: {
marginLeft: theme.spacing(1),
marginRight: theme.spacing(1),
width: 200
},
dense: {
marginTop: 19
},
menu: {
width: 200
}
}));
const currencies = [
{
value: "USD",
label: "$"
},
{
value: "EUR",
label: "€"
},
{
value: "BTC",
label: "฿"
},
{
value: "JPY",
label: "¥"
}
];
function TextFields() {
const classes = useStyles();
const [values, setValues] = React.useState({
name: "Cat in the Hat",
age: "",
multiline: "Controlled",
currency: "EUR"
});
const textFieldRef = React.useRef(null);
React.useEffect(() => {
const handleWheel = e => e.preventDefault();
textFieldRef.current.addEventListener("wheel", handleWheel);
return () => {
textFieldRef.current.removeEventListener("wheel", handleWheel);
};
}, []);
const handleChange = name => event => {
setValues({ ...values, [name]: event.target.value });
};
return (
<form className={classes.container} noValidate autoComplete="off">
<TextField
id="standard-number"
label="Regular Number field"
value={values.age}
onChange={handleChange("age")}
type="number"
className={classes.textField}
InputLabelProps={{
shrink: true
}}
margin="normal"
/>
<TextField
id="standard-number"
label="Number Field with onWheel handler. Watch the console"
value={values.age}
onChange={handleChange("age")}
type="number"
className={classes.textField}
InputLabelProps={{
shrink: true
}}
margin="normal"
ref={textFieldRef}
/>
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
<p>text to create a long form you will have to scroll</p>
<br />
</form>
);
}
export default TextFields; |
nice one @joshwooding, thanks! |
An easy fix also working for new Chrome is: <TextField type="number" onWheel={ event => event.currentTarget.blur() }} /> |
@peterbartos Only working solution so far seems to be @joshwooding #7960 (comment) |
@barbalex are you sure you tested exactly the |
@peterbartos yeah, it sounds kind of weird that the error mentions Double checking I now see that BUT: I tested this again by deactivating @joshwooding 's solution and adding yours. What completely baffles me: This blurs:
This does not blur:
|
Just in case someone lands here looking for a working example, here is my TextField component. It is used with formik: import React, { useCallback, useEffect, useRef } from 'react'
import Input from '@material-ui/core/Input'
import InputLabel from '@material-ui/core/InputLabel'
import FormControl from '@material-ui/core/FormControl'
import FormHelperText from '@material-ui/core/FormHelperText'
import styled from 'styled-components'
import { observer } from 'mobx-react-lite'
const StyledFormControl = styled(FormControl)`
padding-bottom: 19px !important;
> div:before {
border-bottom-color: rgba(0, 0, 0, 0.1) !important;
}
`
const MyTextField = ({
field,
form,
label,
type = 'text',
multiLine = false,
disabled = false,
hintText = '',
helperText = '',
required = false,
}) => {
const { onChange, onBlur, value, name } = field
const { errors, handleSubmit } = form
const error = errors[name]
// only working solution to prevent whell scrolling from changing number values
// see: https://github.com/mui-org/material-ui/issues/7960#issuecomment-497945204
const textFieldRef = useRef(null)
useEffect(() => {
const handleWheel = e => e.preventDefault()
textFieldRef.current.addEventListener('wheel', handleWheel)
return () => {
textFieldRef.current.removeEventListener('wheel', handleWheel)
}
}, [])
// value should immediately update when pressing Enter
const onKeyDown = useCallback(e => {
if (e.key === 'Enter') {
handleSubmit()
// show user something happened
e.currentTarget.blur()
}
})
return (
<StyledFormControl
fullWidth
disabled={disabled}
error={!!error}
aria-describedby={`${label}ErrorText`}
>
<InputLabel htmlFor={label} shrink required={required}>
{label}
</InputLabel>
<Input
id={name}
ref={textFieldRef}
name={name}
value={value || ''}
type={type}
multiline={multiLine}
onChange={onChange}
onBlur={onBlur}
onKeyDown={onKeyDown}
placeholder={hintText}
autoComplete="off"
autoCorrect="off"
autoCapitalize="off"
/>
{!!error && (
<FormHelperText id={`${label}ErrorText`}>{error}</FormHelperText>
)}
{!!helperText && (
<FormHelperText id={`${label}HelperText`}>{helperText}</FormHelperText>
)}
</StyledFormControl>
)
}
export default observer(MyTextField) |
A great alternative solution #10582 (comment) |
* fix bug with search bar in code editor * Support of float input type * Disabled autocomplete in input fields * Removed annoying Input spinners https://codepen.io/ahastudio/pen/eVovMv * Prevents change of numbers with mouse wheel mui/material-ui#7960 * Removed number scrolling on keyboard arrow * Backend bug fix * Prettified "cross-remove" button * Added \n to newfile * update version Co-authored-by: Dmitry Brazhenko <[email protected]>
* Support of float input type * Disabled autocomplete in input fields * Removed annoying Input spinners https://codepen.io/ahastudio/pen/eVovMv * Prevents change of numbers with mouse wheel mui/material-ui#7960 * Removed number scrolling on keyboard arrow * Backend bug fix * Prettified "cross-remove" button * Added \n to newfile * Updated displayed datetime format * Revert "Updated displayed datetime format" This reverts commit a432546. * first version of correct datetime in operation editor * Updated and used function utcTimeToLocal * Fixed bug updated/created Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Ivan Khomyakov <[email protected]>
* build fix: add dateformat * fix style in deprecate dialog * Update date format (#52) * Support of float input type * Disabled autocomplete in input fields * Removed annoying Input spinners https://codepen.io/ahastudio/pen/eVovMv * Prevents change of numbers with mouse wheel mui/material-ui#7960 * Removed number scrolling on keyboard arrow * Backend bug fix * Prettified "cross-remove" button * Added \n to newfile * Updated displayed datetime format * Revert "Updated displayed datetime format" This reverts commit a432546. * first version of correct datetime in operation editor * Updated and used function utcTimeToLocal * Fixed bug updated/created Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Ivan Khomyakov <[email protected]> * rm unnecessary import; add output to filename var in local executor * give more space for output name * Kubernetes operation (#55) * +k8s operation prototype * add request/limit memory * fix k8s operator * flake8 * add logging line * use template config instead of versioning it * update version * rm config from standard docker image Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Dmitry Brazhenko <[email protected]>
* build fix: add dateformat * fix style in deprecate dialog * Update date format (#52) * Support of float input type * Disabled autocomplete in input fields * Removed annoying Input spinners https://codepen.io/ahastudio/pen/eVovMv * Prevents change of numbers with mouse wheel mui/material-ui#7960 * Removed number scrolling on keyboard arrow * Backend bug fix * Prettified "cross-remove" button * Added \n to newfile * Updated displayed datetime format * Revert "Updated displayed datetime format" This reverts commit a432546. * first version of correct datetime in operation editor * Updated and used function utcTimeToLocal * Fixed bug updated/created Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Ivan Khomyakov <[email protected]> * rm unnecessary import; add output to filename var in local executor * give more space for output name * Kubernetes operation (#55) * +k8s operation prototype * add request/limit memory * fix k8s operator * flake8 * add logging line * use template config instead of versioning it * update version * rm config from standard docker image * add k8s icon * add lock in worker update to address #57 * mount config in dev environment * cache the results of cacheable operations * add gpu support to k8s operation * use new kubectl interface * update to beta * update version * fix circleci Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Dmitry Brazhenko <[email protected]>
* build fix: add dateformat * fix style in deprecate dialog * Update date format (#52) * Support of float input type * Disabled autocomplete in input fields * Removed annoying Input spinners https://codepen.io/ahastudio/pen/eVovMv * Prevents change of numbers with mouse wheel mui/material-ui#7960 * Removed number scrolling on keyboard arrow * Backend bug fix * Prettified "cross-remove" button * Added \n to newfile * Updated displayed datetime format * Revert "Updated displayed datetime format" This reverts commit a432546. * first version of correct datetime in operation editor * Updated and used function utcTimeToLocal * Fixed bug updated/created Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Ivan Khomyakov <[email protected]> * rm unnecessary import; add output to filename var in local executor * give more space for output name * Kubernetes operation (#55) * +k8s operation prototype * add request/limit memory * fix k8s operator * flake8 * add logging line * use template config instead of versioning it * update version * rm config from standard docker image * add k8s icon * add lock in worker update to address #57 * mount config in dev environment * cache the results of cacheable operations * add gpu support to k8s operation * use new kubectl interface * update to beta * update version * fix circleci * fix bug with cache: legacy from 0.* * update version Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Dmitry Brazhenko <[email protected]>
* build fix: add dateformat * fix style in deprecate dialog * Update date format (#52) * Support of float input type * Disabled autocomplete in input fields * Removed annoying Input spinners https://codepen.io/ahastudio/pen/eVovMv * Prevents change of numbers with mouse wheel mui/material-ui#7960 * Removed number scrolling on keyboard arrow * Backend bug fix * Prettified "cross-remove" button * Added \n to newfile * Updated displayed datetime format * Revert "Updated displayed datetime format" This reverts commit a432546. * first version of correct datetime in operation editor * Updated and used function utcTimeToLocal * Fixed bug updated/created Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Ivan Khomyakov <[email protected]> * rm unnecessary import; add output to filename var in local executor * give more space for output name * Kubernetes operation (#55) * +k8s operation prototype * add request/limit memory * fix k8s operator * flake8 * add logging line * use template config instead of versioning it * update version * rm config from standard docker image * add k8s icon * add lock in worker update to address #57 * mount config in dev environment * cache the results of cacheable operations * add gpu support to k8s operation * use new kubectl interface * update to beta * update version * fix circleci * fix bug with cache: legacy from 0.* * update version * Add File operation (#62) * initial file dialog * files support in executors * using single endpoint config parameter * add static support to node view * fix lint * add file preview * cleanup * update version * Fix make dev (#64) - add install to docker-compose-dev.yml by installing dependencies before npm start - add .dockerignore to run make dev after data file is made * Rename .dockerignore (#66) * Fix make dev - add install to docker-compose-dev.yml by installing dependencies before npm start - add .dockerignore to run make dev after data file is made * Rename .dockerfile to .dockerignore to allow docker to run with data file * update version Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: houjo <[email protected]>
* build fix: add dateformat * fix style in deprecate dialog * Update date format (#52) * Support of float input type * Disabled autocomplete in input fields * Removed annoying Input spinners https://codepen.io/ahastudio/pen/eVovMv * Prevents change of numbers with mouse wheel mui/material-ui#7960 * Removed number scrolling on keyboard arrow * Backend bug fix * Prettified "cross-remove" button * Added \n to newfile * Updated displayed datetime format * Revert "Updated displayed datetime format" This reverts commit a432546. * first version of correct datetime in operation editor * Updated and used function utcTimeToLocal * Fixed bug updated/created Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Ivan Khomyakov <[email protected]> * rm unnecessary import; add output to filename var in local executor * give more space for output name * Kubernetes operation (#55) * +k8s operation prototype * add request/limit memory * fix k8s operator * flake8 * add logging line * use template config instead of versioning it * update version * rm config from standard docker image * add k8s icon * add lock in worker update to address #57 * mount config in dev environment * cache the results of cacheable operations * add gpu support to k8s operation * use new kubectl interface * update to beta * update version * fix circleci * fix bug with cache: legacy from 0.* * update version * Add File operation (#62) * initial file dialog * files support in executors * using single endpoint config parameter * add static support to node view * fix lint * add file preview * cleanup * update version * Fix make dev (#64) - add install to docker-compose-dev.yml by installing dependencies before npm start - add .dockerignore to run make dev after data file is made * Rename .dockerignore (#66) * Fix make dev - add install to docker-compose-dev.yml by installing dependencies before npm start - add .dockerignore to run make dev after data file is made * Rename .dockerfile to .dockerignore to allow docker to run with data file * update version * Dev (#71) * added cogs * Succefully integrated setting cookies and /setting * made it so the state was hosted in app * added node Display setting * created endpoint to connect configs to settings * finished endpoint and handeling * Turned Setting page into a modal * Added settings as modal added endpoint to access * Revert "Dev (#71)" (#72) This reverts commit f1dc8ea. * User Profile page (#74) * User Settings / User View page * IAM Policies for users: IS_ADMIN, CAN_VIEW_OPERATIONS etc. * User can change password, display name and operation view mode * Added rudementary registration (#76) (#80) * Added rudementary registration (#76) * Added rudementary registration * intermitent changes * interstage * Fix for pr Co-authored-by: Ivan <[email protected]> * rm unused file * integrate sign up page Co-authored-by: houjo <[email protected]> * rm dashboard * rm header * resolve caps problem in path * adapt error page for other than 404 errors * rename logout to sign out * fix vulnerability * post node iam policies * use dark skin in table preview * hide cancel button unless it's a run * show the user who runs an operation rather than the author * fix a bug with assigning the author * finally hide cancel button in templates * use original_node_id in runs * support can_view* roles * update version * rm debug logging * lint fix * raise instead of assert * rm unnecessary logs * intermediate changes * show tour when start plynx for the first time * update version Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: houjo <[email protected]>
* build fix: add dateformat * fix style in deprecate dialog * Update date format (#52) * Support of float input type * Disabled autocomplete in input fields * Removed annoying Input spinners https://codepen.io/ahastudio/pen/eVovMv * Prevents change of numbers with mouse wheel mui/material-ui#7960 * Removed number scrolling on keyboard arrow * Backend bug fix * Prettified "cross-remove" button * Added \n to newfile * Updated displayed datetime format * Revert "Updated displayed datetime format" This reverts commit a432546. * first version of correct datetime in operation editor * Updated and used function utcTimeToLocal * Fixed bug updated/created Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Ivan Khomyakov <[email protected]> * rm unnecessary import; add output to filename var in local executor * give more space for output name * Kubernetes operation (#55) * +k8s operation prototype * add request/limit memory * fix k8s operator * flake8 * add logging line * use template config instead of versioning it * update version * rm config from standard docker image * add k8s icon * add lock in worker update to address #57 * mount config in dev environment * cache the results of cacheable operations * add gpu support to k8s operation * use new kubectl interface * update to beta * update version * fix circleci * fix bug with cache: legacy from 0.* * update version * Add File operation (#62) * initial file dialog * files support in executors * using single endpoint config parameter * add static support to node view * fix lint * add file preview * cleanup * update version * Fix make dev (#64) - add install to docker-compose-dev.yml by installing dependencies before npm start - add .dockerignore to run make dev after data file is made * Rename .dockerignore (#66) * Fix make dev - add install to docker-compose-dev.yml by installing dependencies before npm start - add .dockerignore to run make dev after data file is made * Rename .dockerfile to .dockerignore to allow docker to run with data file * update version * Dev (#71) * added cogs * Succefully integrated setting cookies and /setting * made it so the state was hosted in app * added node Display setting * created endpoint to connect configs to settings * finished endpoint and handeling * Turned Setting page into a modal * Added settings as modal added endpoint to access * Revert "Dev (#71)" (#72) This reverts commit f1dc8ea. * User Profile page (#74) * User Settings / User View page * IAM Policies for users: IS_ADMIN, CAN_VIEW_OPERATIONS etc. * User can change password, display name and operation view mode * Added rudementary registration (#76) (#80) * Added rudementary registration (#76) * Added rudementary registration * intermitent changes * interstage * Fix for pr Co-authored-by: Ivan <[email protected]> * rm unused file * integrate sign up page Co-authored-by: houjo <[email protected]> * rm dashboard * rm header * resolve caps problem in path * adapt error page for other than 404 errors * rename logout to sign out * fix vulnerability * post node iam policies * use dark skin in table preview * hide cancel button unless it's a run * show the user who runs an operation rather than the author * fix a bug with assigning the author * finally hide cancel button in templates * use original_node_id in runs * support can_view* roles * update version * rm debug logging * lint fix * raise instead of assert * rm unnecessary logs * intermediate changes * show tour when start plynx for the first time * update version * hotfix: demo user settings Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: houjo <[email protected]>
* build fix: add dateformat * fix style in deprecate dialog * Update date format (#52) * Support of float input type * Disabled autocomplete in input fields * Removed annoying Input spinners https://codepen.io/ahastudio/pen/eVovMv * Prevents change of numbers with mouse wheel mui/material-ui#7960 * Removed number scrolling on keyboard arrow * Backend bug fix * Prettified "cross-remove" button * Added \n to newfile * Updated displayed datetime format * Revert "Updated displayed datetime format" This reverts commit a432546. * first version of correct datetime in operation editor * Updated and used function utcTimeToLocal * Fixed bug updated/created Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Ivan Khomyakov <[email protected]> * rm unnecessary import; add output to filename var in local executor * give more space for output name * Kubernetes operation (#55) * +k8s operation prototype * add request/limit memory * fix k8s operator * flake8 * add logging line * use template config instead of versioning it * update version * rm config from standard docker image * add k8s icon * add lock in worker update to address #57 * mount config in dev environment * cache the results of cacheable operations * add gpu support to k8s operation * use new kubectl interface * update to beta * update version * fix circleci * fix bug with cache: legacy from 0.* * update version * Add File operation (#62) * initial file dialog * files support in executors * using single endpoint config parameter * add static support to node view * fix lint * add file preview * cleanup * update version * Fix make dev (#64) - add install to docker-compose-dev.yml by installing dependencies before npm start - add .dockerignore to run make dev after data file is made * Rename .dockerignore (#66) * Fix make dev - add install to docker-compose-dev.yml by installing dependencies before npm start - add .dockerignore to run make dev after data file is made * Rename .dockerfile to .dockerignore to allow docker to run with data file * update version * Dev (#71) * added cogs * Succefully integrated setting cookies and /setting * made it so the state was hosted in app * added node Display setting * created endpoint to connect configs to settings * finished endpoint and handeling * Turned Setting page into a modal * Added settings as modal added endpoint to access * Revert "Dev (#71)" (#72) This reverts commit f1dc8ea. * User Profile page (#74) * User Settings / User View page * IAM Policies for users: IS_ADMIN, CAN_VIEW_OPERATIONS etc. * User can change password, display name and operation view mode * Added rudementary registration (#76) (#80) * Added rudementary registration (#76) * Added rudementary registration * intermitent changes * interstage * Fix for pr Co-authored-by: Ivan <[email protected]> * rm unused file * integrate sign up page Co-authored-by: houjo <[email protected]> * rm dashboard * rm header * resolve caps problem in path * adapt error page for other than 404 errors * rename logout to sign out * fix vulnerability * post node iam policies * use dark skin in table preview * hide cancel button unless it's a run * show the user who runs an operation rather than the author * fix a bug with assigning the author * finally hide cancel button in templates * use original_node_id in runs * support can_view* roles * update version * rm debug logging * lint fix * raise instead of assert * rm unnecessary logs * intermediate changes * show tour when start plynx for the first time * update version * hotfix: demo user settings * rm unused elements from config; add iam policies * fix bug when users have no settings legacy * update version Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: Dmitry Brazhenko <[email protected]> Co-authored-by: houjo <[email protected]>
thanks . |
|
That is super nice solution!! If a user is scrolling they are usually not wanting to focus on the input too :) |
Thanks @yakubova92 |
onWheel={(event) => event.currentTarget.querySelector('input')?.blur()} |
I can confirm this worked. I tried both currentTarget.blur() and target.blur(). currentTarget.blur() didn't do anything. Just some more information for a future person. |
Works for me, thanks.
|
I am using
|
<TextField type="number" onWheel={ event => event.target.blur() } /> This does the job for me |
This one works for me though it gave an warning in my IDE but works onWheel={event => { event.target.blur()}} |
the best solution. |
For some reason even the ref solution did not work for me. This one worked perfectly |
I saw a solution for this based on jQuery that I really liked, because it's careful to only listen to (and block) onWheel events while the control is focused. So I ported the concept over to React Js - MUI framework's TextField. Here's a git gist: Here's the jQuery solution that I borrowed from: Here's some sample code:
And a sample:
|
This worked for me in mui v5 <TextField
type="number"
onFocus={(e) =>
e.target.addEventListener(
"wheel",
(e) => e.preventDefault(),
{ passive: false }
)
}
/> |
I was using React Hook Forms libraries register method with Mantine this enabled me to successfully prevent the onScroll events |
This solution worked for me:
|
Thanks for solutions :) <TextField
...
onWheel={e =>
e.target instanceof HTMLElement && e.target.blur()
}
/> |
sweet!!! |
Problem description
Scrolling in a number field changes the values. In all the applications I have built so far people have asked me to prevent this behaviour because it sometimes causes corrupted data.
See also https://stackoverflow.com/questions/9712295/disable-scrolling-on-input-type-number/38589039#38589039
Steps to reproduce
Build a TextField of type number. Set focus into it. Scroll with your mousewheel.
Versions
This happens in all browsers in input elements, as far as I know.
Workaround
I have tried this:
But it only seems to work sometimes. No Idea why it only works inconsistently.
Request
Now I see that changing standard behaviour would not be good. But adding this as an option would be very nice.
The text was updated successfully, but these errors were encountered: