-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Changing Select Option #1969
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
Changing Select Option #1969
Conversation
@mlarghydracept I think something like this pseudcode is close-ish: when I call: if (option exists with name) {
if (value === false) { // this is a way to remove options
remove option
}
else {
if (option.name currently == option.value) { // we assume the user wants to update both
option.name = option.value = value;
} else {
option.value = value;
// option.name stays the same
}
}
} else {
add option as normal
} what do you think? |
Thanks for the help! I implemented basically exactly what you wrote. The only small problem is that it is impossible for a user to have two options with the same name as trying to add a new one with the same name will just overwrite the value for the old one. This seems kind of unavoidable without adding an unwieldy boolean argument into the mix. For now this feels pretty user friendly! |
This led to a confusing situation for a student I mentored that resulted in them spending a couple of days trying to understand. They were creating a To make matters worse, some of the columns had unescaped HTML special characters like const opt = document.createElement('option');
opt.innerHTML = name; to make the element. Maybe I missed it, but I don't see mention that options must be unique in the documentation. I'll open a PR for improving the documentation and open an issue for potentially changing this behavior, but I wanted to leave a note here in case anyone else runs into this. I'm not sure if it could be considered, but I'd prefer if the behavior didn't allow changing options via the |
First attempt. Doesn't seem like an ideal design as it requires that you to know both the name and value of the option you want to change.
Open to other suggestions!
Closes #1554