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.

Selector not working inside dependency for uncontrolled components

See original GitHub issue

Prerequisites

Description

The select input inside a schema dependency is not working as intended. The default value is ignored and it is not possible to select a single choice. When there are multiple choices, the workaround is to first change the value and then back to the initial.

Steps to Reproduce

This is best viewed in the provided sample: https://codesandbox.io/s/github/snirp/schemadebug

  • Form A: inside “select2” the value of “option2A” is displayed, but this value is not actually selected. Only “select1” is actually submitted and no validation errors are triggered (although “select2” is a required field. Toggling between “option2A” and “option2B” can be used as a workaround.

  • Form B: the same issue, but the workaround is not available, since there are no choices to toggle between. This is a particularly nasty situation we encountered.

  • Form C: the defaults are provided through formData. This is the workaround we are using.

Expected behavior

Should work just as select input outside the dependency

Actual behavior

See the provided codesandbox

Version

^1.7.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
epicfaacecommented, Aug 12, 2019

@snirp thanks for the explanation, makes sense. When I go to this playground link it is working fine, but that is because Form in the playground is a controlled component (with formData and onChange props passed in). So it seems like this issue only happens for uncontrolled components.

0reactions
stale[bot]commented, Apr 15, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please leave a comment if this is still an issue for you. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: A component is changing an uncontrolled input to be ...
The code works fine but throwing this error on console "Warning: A component is changing an uncontrolled input to be controlled.
Read more >
Uncontrolled Components - React
In React, an <input type="file" /> is always an uncontrolled component because its value can only be set by a user, and not...
Read more >
Selectors Level 4 - W3C
Pseudo-elements do not exist independently in the tree: they are always bound to another element on the page, called their originating element ....
Read more >
FAQ - Ant Design
We also maintain a FAQ issues label for common github issues. ... Yes. antd will treats undefined as uncontrolled but null as controlled...
Read more >
React re-renders guide: everything, all at once - Developer way
Unnecessary re-renders by themselves are not a problem: React is very ... Creating components inside render function of another component is ...
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