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.

Focus on TextField is lost if variant is changed on the fly

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

Current Behavior 😯

If the variant property of a TextField is changed on the fly the focus on the field is lost

Expected Behavior 🤔

Would be nice if focus is kept.

Steps to Reproduce 🕹

Go to https://odtfp.csb.app/

  1. type something in the field
  2. …then type an _ char (which enable the error state)
  3. …see focus being lost
  4. re-focus the field manually
  5. remove the _ (so exit the “error state”
  6. focus is lost again

Context 🔦

What I was trying to achieve is to have a better highlight of the field error so I’m switching from “standard” to “filled” variant on the fly in case of error.

I perfectly know that I can have the same visual behavior just using styles, and I’m going in this direction, but I was not sure if this should be threat as a minor bug or not, so I’m reporting this.

Your Environment 🌎

Tech Version
Material-UI v4.9.9
React 16.12.0

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
eps1loncommented, Apr 28, 2020

I think for uncontrolled components the state would be lost as well. It would definitely be nice to be able to switch variants but the amount of work required isn’t justified compared to the gain. Generally you don’t switch variants since you only have a single variant per form anyway.

0reactions
keulcommented, Apr 29, 2020

@eps1lon @oliviertassinari I updated the codesandox with an uncontrolled example and there’s the same issue. However I really don’t find useful adding any complexity for supporting this edge case. My report was only just in case it was hiding other issues. Changing the variant on the fly is not useful.

Thanks all for your time!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Focus on TextField is lost if variant is changed on the fly #20821
The issue is present in the latest release. I have searched the issues of this repository and believe that this is not a...
Read more >
Flutter TextField is losing data when focus changes
I think issue is not in loosing focus, but rather in the fact that widget is rebuilt, it's class recreated and as consequence...
Read more >
Focus and text fields - Flutter documentation
When a text field is selected and accepting input, it is said to have “focus.” Generally, users shift focus to a text field...
Read more >
Migrating to v5 - Bootstrap
Track and review changes to the Bootstrap source files, documentation, and components to help you migrate from v4 to v5. On this page....
Read more >
First steps with Flutter - Part 3: Responding to user input
Today we're going to explore how to actually do something when the user interacts with the widgets that we've added to our layout....
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