Skip to content

Conversation

@SteffenDE
Copy link
Contributor

Fixes phoenixframework/phoenix_live_view#3742.

When a select contained an empty optgroup

<select>
    <optgroup label="optgroupabove">
        <option selected value="1">a</option>
        <option value="2">b</option>
        <option value="3">c</option>
    </optgroup>
    <optgroup label="optgroupempty"></optgroup>
    <optgroup label="optgroupbelow">
        <option value="4">d</option>
        <option value="5">e</option>
        <option value="6">f</option>
    </optgroup>
</select>

morphdom would stop when encountering the empty optgroup, not patching the nodes below. This is fixed by skipping to the next sibling when an optgroup does not have any children.

Fixes phoenixframework/phoenix_live_view#3742.

When a select contained an empty optgroup

<select>
    <optgroup label="optgroupabove">
        <option selected value="1">a</option>
        <option value="2">b</option>
        <option value="3">c</option>
    </optgroup>
    <optgroup label="optgroupempty"></optgroup>
    <optgroup label="optgroupbelow">
        <option value="4">d</option>
        <option value="5">e</option>
        <option value="6">f</option>
    </optgroup>
</select>

morphdom would stop when encountering the empty optgroup, not patching
the nodes below. This is fixed by skipping to the next sibling when an
optgroup does not have any children.
@SteffenDE
Copy link
Contributor Author

CI fixed in #269.

@chrismccord chrismccord merged commit 526a4e6 into patrick-steele-idem:master Apr 10, 2025
1 check failed
@chrismccord
Copy link
Collaborator

❤️❤️❤️🐥🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty optgroup in select prevents render of selected option on subsequent assigns

2 participants