mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.21k stars 32.09k forks source link

[number input] Mobile focus mode #39275

Open oliviertassinari opened 11 months ago

oliviertassinari commented 11 months ago

Steps to reproduce 🕹

Link to live example:

Steps:

  1. Open https://mui.com/base-ui/react-number-input/#minimum-and-maximum on mobile
  2. Press on one of the buttons

https://github.com/mui/material-ui/assets/3165635/f8526d2e-6878-4886-8fa3-e0abd7b0c80a

Current behavior 😯

See how the input is focused

Expected behavior 🤔

It's not clear to me that we should focus the input. On mobile, it's quite annoying to see the virtual keyboard show when using the button is enough to set the expected value.

It doesn't seem that I'm the only one to be annoyed:

  1. Example with https://www.figma.com/purchase-organization/details

https://github.com/mui/material-ui/assets/3165635/40ef01ff-8383-43ac-875f-7083a3ef68ac

  1. On https://react-spectrum.adobe.com/react-aria/NumberField.html the input is not focused on mobile

Your environment 🌎

npx @mui/envinfo ``` Don't forget to mention which browser you used. Output from `npx @mui/envinfo` goes here. ```
Aditya-Chaurasia11 commented 11 months ago

can you please assign this to me?

Visbhavesh commented 11 months ago

assign it to me

asdotdev commented 11 months ago

This same behaviour occurs in all places where NumberInput(Unstable_NumberInput) is being used as a Mui-focused class name is appending in MuiNumberInput-root on button press too and not only on input press.

omagr commented 11 months ago

@mj12albert

I hope this message finds you well. I was wondering if you're currently working on this particular issue. If not, I would greatly appreciate it if you could consider assigning it to me.

akshayw1 commented 11 months ago

Could you pls assign it to me?

dankgen-tobias commented 2 months ago

Meanwhile you can use the hook https://mui.com/base-ui/react-number-input/#hook and override the onMouseDown event on the increment/decrement button. Then it won't focus anymore, this is because in the code it says

const handleStepperButtonMouseDown = event => {
    event.preventDefault();
    if (inputRef.current) {
      inputRef.current.focus();
    }
  };