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

Set value using attribute only on initial option render #6449

Merged
merged 1 commit into from
Apr 8, 2016

Conversation

sophiebits
Copy link
Collaborator

Tested that you can now type in the middle of a controlled input in Chrome which previously jumped your cursor to the end.

Fixes #6445.

Tested that you can now type in the middle of a controlled input in Chrome which previously jumped your cursor to the end.

Fixes facebook#6445.
@sebmarkbage
Copy link
Collaborator

How sure are you on this fixing the original issue? What's the summary of why this works?

@sophiebits
Copy link
Collaborator Author

This basically reverts #6228. That broke cursor positioning because setting .value on an input (in contrast to other tags like option) doesn't make .hasAttribute('value') true. Then we just need to make <option value=""> properly create an option with an empty value attribute, which I did by setting it manually after creation for options only. This does not work properly for <option> transitioning to <option value=""> but neither did 0.14.

@jimfb
Copy link
Contributor

jimfb commented Apr 8, 2016

I did not like that other fix, I felt like it was janky and was going to lead to edge cases that would bite us. I similarly don't like this one. I'd feel much more comfortable if we went with #6406. We still could; it is rebased and ready-to-go.

Anyway, accepting to unblock ( 👍 )

@sophiebits sophiebits merged commit 2b1bd1d into facebook:master Apr 8, 2016
zpao pushed a commit to zpao/react that referenced this pull request Apr 8, 2016
Set value using attribute only on initial option render
(cherry picked from commit 2b1bd1d)
@zpao zpao added this to the 15.0.1 milestone May 17, 2016
sebmarkbage added a commit that referenced this pull request Apr 11, 2023
This traces back to #6449 and then
another before that.

I think that back then we favored the property over the attribute, and
setting the property wouldn't be enough. However, the default path for
these are now using attributes if we don't special case it. So we don't
need it.

The only difference is that we currently have a divergence for
symbol/function behavior between controlled values that use the
getToStringValue helpers which treat them as empty string, where as
everywhere else they're treated as null/missing.

Since this comes with a warning and is a weird error case, it's probably
fine to change.
github-actions bot pushed a commit that referenced this pull request Apr 11, 2023
This traces back to #6449 and then
another before that.

I think that back then we favored the property over the attribute, and
setting the property wouldn't be enough. However, the default path for
these are now using attributes if we don't special case it. So we don't
need it.

The only difference is that we currently have a divergence for
symbol/function behavior between controlled values that use the
getToStringValue helpers which treat them as empty string, where as
everywhere else they're treated as null/missing.

Since this comes with a warning and is a weird error case, it's probably
fine to change.

DiffTrain build for [343a45f](343a45f)
jerrydev0927 added a commit to jerrydev0927/react that referenced this pull request Jan 5, 2024
This traces back to facebook/react#6449 and then
another before that.

I think that back then we favored the property over the attribute, and
setting the property wouldn't be enough. However, the default path for
these are now using attributes if we don't special case it. So we don't
need it.

The only difference is that we currently have a divergence for
symbol/function behavior between controlled values that use the
getToStringValue helpers which treat them as empty string, where as
everywhere else they're treated as null/missing.

Since this comes with a warning and is a weird error case, it's probably
fine to change.

DiffTrain build for [343a45ffa48065e60699bbe68f82d7b62fa02840](facebook/react@343a45f)
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
This traces back to facebook#6449 and then
another before that.

I think that back then we favored the property over the attribute, and
setting the property wouldn't be enough. However, the default path for
these are now using attributes if we don't special case it. So we don't
need it.

The only difference is that we currently have a divergence for
symbol/function behavior between controlled values that use the
getToStringValue helpers which treat them as empty string, where as
everywhere else they're treated as null/missing.

Since this comes with a warning and is a weird error case, it's probably
fine to change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants