Skip to content
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

[Joy][TextField] Invalid componentProps mapping #34217

Closed
2 tasks done
zignis opened this issue Sep 7, 2022 · 1 comment
Closed
2 tasks done

[Joy][TextField] Invalid componentProps mapping #34217

zignis opened this issue Sep 7, 2022 · 1 comment
Labels
component: text field This is the name of the generic UI component, not the React module! design: joy This is about Joy Design, please involve a visual or UX designer in the process

Comments

@zignis
Copy link
Contributor

zignis commented Sep 7, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Correct me if I am wrong, is it the expected behaviour that when trying to set the maxlength attribute on the textfield using componentProps prop, the attribute gets passed to root element instead of the input slot?

<TextField
  componentProps={{
    input: {
      maxLength: 128,
    },
  }}
/>

This renders to:

<div maxlength="128" class="JoyInput-root ...">
  <input type="text" class="JoyInput-input ..." >
</div>

Notice how the maxlength attribute is passed to the root element instead of the native input element.

Workaround

...
    <Textfield
      componentsProps={{
        input: {
          componentsProps: {
            input: {
              maxLength: 128,
            },
          },
        },
      }}
    />
...

Expected behavior 🤔

Input component props should get passed to the native input element. Adding inputProps prop to the TextField component might help with this.

Steps to reproduce 🕹

CodeSandbox: https://codesandbox.io/s/nervous-water-k0ktu4?file=/src/App.tsx

Context 🔦

Trying to set native input element attributes on the TextField component.

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@zignis zignis added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 7, 2022
@zignis
Copy link
Contributor Author

zignis commented Sep 7, 2022

Similar #34176

@zignis zignis closed this as completed Sep 7, 2022
@michaldudak michaldudak removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 20, 2022
@zannager zannager added component: text field This is the name of the generic UI component, not the React module! design: joy This is about Joy Design, please involve a visual or UX designer in the process labels Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: text field This is the name of the generic UI component, not the React module! design: joy This is about Joy Design, please involve a visual or UX designer in the process
Projects
None yet
Development

No branches or pull requests

3 participants