react: The `defaultValue` of `
I would like to report a bug.
In re-filing another outstanding bug that was closed despite being reproducible, I decided to create a repro case.
Since the repro involves setting defaultValue
on a <select>
, I confronted the human inability to remember whether HTML is zero-indexed or one-indexed.
Since the repro also involves determining whether a given <option>
is selectable, I decided to just have a control with four <option>
s and to select 3, to see which I’d get - the third or the fourth.
Joke’s on me. I got neither. I got the first selectable <option>
.
A winner is testcase. If the series is 1-indexed you should see joe
; if 0-indexed you should see stan
. Instead you see bob
.
As such I currently believe that defaultValue
is not honored on select
.
This is the first time I’ve noticed this. I have only tested it under 16.0.0
.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 32 (13 by maintainers)
@aweary - please disinvolve yourself from this ticket
it would be less work to make the fiddle yourself than to keep arguing with me. all you’re doing is convincing me that i should no longer contribute to react.
i’ve opened a lot more than three issues with you. you just don’t know who i am.
i’m not interested in getting the “we’re just volunteers” speech. so am i. i don’t get the credit for being a collaborator, i already did the work you want, and you’re just too lazy to open it.
if you comment on this ticket again i’m closing it again and leaving it closed. you guys haven’t been able to find this for four years, despite that it’s one of the basic w3 test cases.
i’d be happy to leave react broken for another four years if the collaborators aren’t interested enough in quality to cut and paste a single stretch of text a single time.
@StoneCypher you’ve only opened three issues with us, including this one and https://github.com/facebook/react/issues/11100. In the issue that was closed (https://github.com/facebook/react/issues/2803) you didn’t provide a reproducible test case, but thankfully @nhunzaker spent the time putting together the JSFiddle you linked in this issue.
There’s a reason we’re asking for a JSFiddle: we can’t easily read the source code for your test case, and we can’t make modifications to it to debug. Providing a hosted example without the source is not helpful to us.
Please understand that every single person here trying to help you is a volunteer doing this in our free time; making it easier for us to help you goes a long way. Acting rude only makes it more difficult for us to work together and resolve your issue, so please take that into consideration.
@StoneCypher I know this is frustrating for you, I understand your old issue was open for a long time and we’re sorry about that. We want to work to resolve this, but this kind of behavior is not acceptable and if it continues we’ll have to take action. Please keep it civil and focused on the technical discussion. Thanks.
I already said no to that.
This bug is four years old. I’ve already written you three productions.
You can cut and paste that if you want to.
I’ve opened eight tickets about this so far. It’s been four years.
Your team closed an active ticket about this without even investigating it five days ago.
You’ve gotten a lot more than a little help.
@nhunzaker - Open the link, open your console, observe the clear instructions that show the problem is real. Move forwards as you see fit.
I am not interested in copy and pasting the reproduction case in this ticket into jsfiddle. Please take quality more seriously. Please stop asking me to copy repro cases for you.
@aweary - The repro case you’re ignoring shows that the thing you found is not correct. Please don’t involve yourself on this ticket anymore. Thanks
@nhunzaker - This is the third time I am declining to copy the working reproduction that you were already given into jsfiddle.
The last time someone asked I closed the ticket
@jquense looks like it’s an issue with the whitespace in option’s value. The
value
property on an option element strips whitespace so if you have" -- Select Eisenhower -- "
it will fail to match due to the leading and trailing whitespace.Here’s that same example without the whitespace: https://jsfiddle.net/hkr4f5yr/ you can see it matches the native DOM behavior.
So the solution here would be separate from https://github.com/facebook/react/pull/11057. We could trim
defaultValue
when doing the comparison, or try to use something likeinnerText
that doesn’t trim the whitespace. I’m not sure yet what the best solution would be.Can you please post your test case in jsfiddle if the one above doesn’t cover the bug? Thanks
@aweary - and if you really can’t find it?
<key>ctrl+f</key> testcase
it’s in the issue. just read the issue
Maybe someone else will see this and act
@StoneCypher sorry, the only JSFiddle you provided was https://jsfiddle.net/84v837e9/140/ and I already identified what the issue was there.
If there’s another JSFiddle in a previous issue it would really help us if you could just link us to it, we have hundreds and hundreds of closed issues so sometimes it’s hard to go back and find one specific one.
Can you post the repro in js fiddle so we can read the code and mess with it? Thanks!
JSFiddle: https://jsfiddle.net/gqb0227f/
Semi-related codepen of native behavior: https://codepen.io/nhunzaker/pen/LzeOPb
I am not sure if directly assigning
value
is accurate, but it does result in the select showing “blank”, at least in chrome.As far as I know, our internal methods involve finding the matching option and selecting it. Should we assign value directly? Does that work in every browser?
@aweary - the replication you were given here by me does not have a space in the option’s value, and remains broken.
I’m not sure why you were able to repair the other guy’s silly and overcomplicated code that way.
The one I gave you is not subject to that form of fix
Thanks! Cc @aweary perhaps your reset PR could also cover this if we are saying it should. If it’s a pain tho my instinct would be to recommend controlling the select for this case