-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Docs: select option documentation is unclear #5776
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
Comments
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you! |
Thanks @ggorlen. I am adding the DOM stewards @outofambit, @SarveshLimaye, @SamirDhoke to this discussion. |
Thanks @Qianqianye for adding me to this discussion. @ggorlen I want to understand whether we want to add two options with same name and value when called select.option() twice or just replace the value of the existing option, if any ? |
Well, the existing approach is to change the value of the existing option, which seems to have originally been discussed in #1554 and implemented in #1969. I responded to that pull here explaining that the design choice seems to lead to various bugs and (to my mind) surprising behavior. My personal opinion is that the way the option was implemented was prolematic from the start. It's an unusual design choice to impose that select option text be unique and I think there are better ways to enable value changes that don't treat the text content as a unique identifier. But stopping short of revisiting the design that's been in the code since 2017, the goal of this PR is to simply clarify the existing Kind of long-winded (sorry!), but hopefully this answers the question. |
Yes. sorry i didn't see the pull request first, it's one of my very first contribution conversations. Thanks for pointing out the links, it helped me to understand the solution. |
Increasing Access
Better documenting the confusing behavior of
<select>
/<option>
can help beginners new to coding avoid gotchas that can lead to frustration.Most appropriate sub-area of p5.js?
Feature enhancement details
See #1969 (comment) for an in-depth contextual explanation of a lack of unique
<option>
element text contents leading toundefined
and causing a confusing situation for a student.We should more clearly document that
<option>
text contents are expected to be unique--when.option(optionName)
is called with non-unique values, rather than new options being added as expected, existing options' values are set toundefined
.A minimal example is:
Here, one might expect a dropdown with two
"a"
elements, but instead, one<option>
is created withvalue="undefined"
rather thanvalue="a"
:Contrast this to comparable native DOM code:
Which creates the unsurprising:
The text was updated successfully, but these errors were encountered: