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

[TextField/Menu] Menu auto focus causes TextField to lose focus #4387

Closed
liddellj opened this issue May 31, 2016 · 8 comments
Closed

[TextField/Menu] Menu auto focus causes TextField to lose focus #4387

liddellj opened this issue May 31, 2016 · 8 comments
Labels
bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module!

Comments

@liddellj
Copy link

Problem description

With a controlled TextField, the field loses focus when re-rendered in the precense of a Menu component elsewhere that does not have disableAutoFocus set to true. Even if the menu is not open, and has not been interacted with.

Steps to reproduce

  • Add a controlled TextField to your app
  • Add a Menu with no disableAutoFocus prop (this will default the prop to false)
  • Click in the TextField such that it takes focus, note that the underline appears
  • Enter a single character
  • Observe that the TextField loses focus on re-render
  • Change the Menu so that disableAutoFocus is set to true
  • Enter a single character in the TextField
  • Observe that the TextField no longer loses focus

Versions

  • Material-UI: 0.15.0
  • React: 15.0.2
  • Browser: Chrome 51.0.2704.63 (64-bit)
@muibot muibot added the Triage label May 31, 2016
@mpontikes mpontikes mentioned this issue Aug 5, 2016
13 tasks
@oliviertassinari oliviertassinari added the component: text field This is the name of the generic UI component, not the React module! label Oct 19, 2016
@philcruz
Copy link

I'm hitting the same issue, TextField is losing focus. In my case, I have a SelectField with MenuItems. The SelectField doesn't have the disableAutoFocus property. Any other workarounds?

@philcruz
Copy link

philcruz commented Apr 2, 2017

On further investigation, it wasn't the SelectField. I had a Menu, that was part of a Drawer. Even though the Drawer was not open it was causing the issue. Setting disableAutoFocus as has been suggested resolved it. I should also note this was not an issue in Chrome desktop. It was only a problem on Cordova/Android (didn't check iOS). When touching the TextField the keyboard would come up then immediately go away (because the Menu was taking focus) and the TextField did not have focus so you effectively could not type in the TextField.

@torstenrudolf
Copy link

oooohhh, jsut ran into same issue. took me aeons to debug ;-(

@oliviertassinari
Copy link
Member

We have been porting the component on the v1-beta branch. We reimplemented it from the ground-up. While we haven't tested it, I think that the issue is most likely fixed on that branch. Hence, I'm closing it.
Still, we will accept PR fixes until v1-beta takes over the master branch.

@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Jul 28, 2017
@raghavendracs
Copy link

Finally !!!! After spending hours on trying to debugging this and going all over the place in redux-forms this finally came to this which fixed the exact same issue for me too !

jgullstr added a commit to jgullstr/ga-ui that referenced this issue Jan 14, 2018
@sandbox4013
Copy link

For those, who has no luck with previous suggestions - try this one

<Menu
  disableEnforceFocus
  disableRestoreFocus
  {...otherProps}
/>

@justcode-hj
Copy link

Hey There !
Just needed to know, where to write disableAutoFocus ?

@mr-amarok
Copy link

@sandbox4013 thanks ! Your suggiestion was my last hope and it worked !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

10 participants