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

[InputUnstyled (MUI Base)] Add inputRef prop, similar to MUI

Open cpotey opened this issue 3 years ago • 0 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Summary 💡

It would be good to have access to the inputRef of <InputUnstyled /> - similar to how [https://mui.com/material-ui/api/input/#props](MUI's input) works.

Currently when you use a ref on <InputUnstyled />, it refers to the wrapping div rather than the input itself.

<div class="MuiInput-root"> <-- this
    <input type="text" class="MuiInput-input" value="">
</div>

The input would be more valuable to have access to ref with than the root element.

Examples 🌈

https://mui.com/material-ui/api/input/#props

Motivation 🔦

This would make it easier to get the value from the ref.

In my scenario, I'm trying to auto-focus the <InputUnstyled> inside an <ModalUnstyled>, but using a ref (to autofocus on open of the modal) focuses the wrapping div instead For more context, adding the autoFocus prop on the <InputUnstyled> doesn't work either

cpotey avatar Dec 14 '22 14:12 cpotey