controlled input on select tag requires both select value AND option selected
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.3k
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
More of a documentation request than a feature request -- this is how to do a "controlled" (in the React parlance) version of a select tag:
const select = (options, value) =>
yo`<select value="${value}">
${options.map((o) =>
yo`<option value="${o.value}"
${value === o.value ? "selected" : ""}>
${o.label}
</option>`
)}
</select>`
Note that you need to both set a value on the <select> tag and set the selected attribute on the selected <option>.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue body contains the controlled select example and explains the required select and option attributes. No documentation file or test is named, so first locate the project's documentation entry point and check how usage examples are organized. Done means documenting this behavior clearly with the example or equivalent guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation, frontend
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100