material-ui
material-ui copied to clipboard
[base][Input] inputProps onKeyDown is not working
Duplicates
- [X] I have searched the existing issues
Latest version
- [X] I have tested the latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/broken-cookies-k6px3x?file=/demo.tsx:1459-1539
Steps:
- Enter text to the input
- "onKeyDown" is not output to the console log
Current behavior 😯
onKeyDown is not triggered
Expected behavior 🤔
onKeyDown is triggered
Context 🔦
I forget the specific version, but onKeyDown used to work before, but does not seem to work now. Is this an expected specification?
Your environment 🌎
npx @mui/envinfo
Please see the codesandbox dependencies
@ysds Thanks for reporting this 🙂
onKeyDown as a normal prop (not through slotProps
) will work
<CustomInput
aria-label="Demo input"
placeholder="Type something…"
onKeyDown={() => console.log('props onKeyDown')}
/>
Here is a working sandbox: https://codesandbox.io/s/https-github-com-mui-material-ui-issues-37134-vxjbpy?file=/demo.tsx
Should we allow both to work 🤔 ? CC @michaldudak @mui/core
since onChange
when set from slotProps
is working, i think other even handlers should also work. or else developers will have hard time figuring out which are working and which aren't. what do you think?
Should we allow both to work 🤔 ?
Yes, definitely.
@sai6855 are you working on this? If not, could you please assign this to me?
@nicolas-ot ah yes I'm planning to work on this