material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[number input] Mobile focus mode

Open oliviertassinari opened this issue 2 years ago • 6 comments

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.

oliviertassinari avatar Oct 03 '23 00:10 oliviertassinari

can you please assign this to me?

Aditya-Chaurasia11 avatar Oct 03 '23 07:10 Aditya-Chaurasia11

assign it to me

Visbhavesh avatar Oct 03 '23 07:10 Visbhavesh

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.

asdotdev avatar Oct 03 '23 12:10 asdotdev

@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.

omagr avatar Oct 03 '23 15:10 omagr

Could you pls assign it to me?

akshayw1 avatar Oct 04 '23 04:10 akshayw1

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();
    }
  };

tobias-zip avatar Jun 28 '24 13:06 tobias-zip