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.

Input component destroys muiFormControl context which breaks complex components

See original GitHub issue

https://github.com/mui-org/material-ui/blob/0385a631c992afc3a2a94c7ae35975a018ca4173/src/Input/Input.js#L241

I have a react-select component wrapped into FormControl and Input according to the explanation on your website. I think I added FormControl myself to control the behaviour of Label which I added to make it resemble all the other input components.

So a component which wraps react-select and is provided as inputComponent to Input triggers onBlur and onFocus from muiFormControl context in order to control the behaviour for Select.

However this context is not propagated any longer down the line.

Because FormControl doesn’t accept focused as an argument, controlling it’s state of focus is impossible in this case now

Is it possible to make Input behaviour in part where it erases the context optional?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Mar 15, 2018

Thanks for the gist. Hopefully, It will help someone in the community.

0reactions
iamdanthedevcommented, Mar 15, 2018

Hello Olivier Thanks for information regarding shrink, I didn’t know about it

Yesterday I have solved the problem by separating <Input inputComponent... /> into a separate component which reads context and manages muiFormControl.onDirty and onClean itself, instead of relying on the underlying component (SelectWrapped) to do so, as the latter doesn’t have that context any longer.

Maybe this (still a bit messy) file will be of any use: https://gist.github.com/iamdanthedev/2a70e95d8964979f689721a34b2d15b3

(L255-264)

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Input component destroys muiFormControl context ... - GitHub
Input component destroys muiFormControl context which breaks complex ... There are two main components: SelectField (the root component) and ...
Read more >
Material Form Field and TextFieldRoot overwrite theme with ...
You are passing procedureStyles.textField via the input key of the classes prop in InputProps . That targets the innermost input element (and I ......
Read more >
Design Patterns with React Easy State | by Bertalan Miklos
React Easy State is a transparent reactive state management library with two functions and two accompanying rules. Always wrap your components with view()...
Read more >
youtube-danmaku - Source code - Greasy Fork
Consistency between these values is important. background: { paper: common.white, ... i < parts.length; i++) { scoped += scope + " " +...
Read more >
Free Automated Malware Analysis Service - powered by Falcon ...
Submit malware for free analysis with Falcon Sandbox and Hybrid Analysis technology. Hybrid Analysis develops and licenses analysis tools to fight malware.
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