question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TextField] TextField doesn't support a custom selectInput

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

Select has an input prop that provide a custom input for select whereas TextField has only variant prop for choosing input view. It seems like inconsistency and TextField “cuts” a possibility to customise Select.

Current Behavior 😯

Select has an input prop which is handled here Here is fragment of Select.

const InputComponent =
    input ||
    {
      standard: <Input />,
      outlined: <OutlinedInput label={label} labelWidth={labelWidth} />,
      filled: <FilledInput />,
    }[variant];

Unlike in TextField only variant can be choosen.

  const InputComponent = variantComponent[variant];

Expected Behavior 🤔

Input can be choosen in TextField like in Select in example above.

const InputComponent = input || variantComponent[variant];

Motivation 🔦

Use Select inside TextField in the same way as Select separately.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
aikvcommented, Dec 24, 2020

Thank you for answering. Seems like SelectField as separate component probably resolve the problem, if custom component can be passed.

What @AwK55 is described with Select is documented at https://next.material-ui.com/components/selects/#customized-selects

Select already have this ability but agregate component TextField not.

The current solution is

It doesn’t work because all handlers such as onChange, onFocus is passed to components in variantComponent array.

1reaction
oliviertassinaricommented, Dec 26, 2020

@AwK55 Oh thanks for providing these extra details. In this case, maybe the first proposal of Marija would be best, a new input prop, which provides the same DX as when using the Select component.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[TextField] TextField doesn't support a custom selectInput
Select has an input prop that provide a custom input for select whereas TextField has only variant prop for choosing input view. It...
Read more >
MUI - Outlined select label is not rendering properly
Solution 1: Use TextField. This is what TextField is for. It uses FormControl and InputLabel internally and make sure they work well ...
Read more >
ASP.NET Core Blazor forms and input components
The Blazor framework supports forms and provides built-in input components: ... Data Annotations Validator component and custom validation.
Read more >
Events: change, input, cut, copy, paste
Let's cover various events that accompany data updates. Event: change. The change event triggers when the element has finished changing.
Read more >
HTML attribute: readonly - HTML: HyperText Markup Language
The attribute is not supported or relevant to <select> or input types that ... and being disabled, so the readonly attribute does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found