Repository navigation
Commit 5d4e674
User
Fix #270: Preserve multi-select selection state on form re-render
The _find_selected_options transform was stripping the 'selected'
attribute from <option> elements and relying solely on defaultValue
on the <select> element. This works on initial mount (Preact applies
defaultValue once), but on re-render after form submission, Preact
only diffs attributes — it does not re-apply defaultValue. Since the
selected attribute had been removed from <option> elements, Preact
had no way to know which options should be selected, and the form
lost all multi-select selections after submission.
Fix: keep the selected attribute on <option> elements. defaultValue
is still set on <select> for initial mount compatibility, but
selected on <option> ensures re-renders correctly restore state.1 parent 3f59f80 commit 5d4e674
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
93 | 101 | | |
94 | 102 | | |
95 | 103 | | |
| |||
98 | 106 | | |
99 | 107 | | |
100 | 108 | | |
101 | | - | |
102 | 109 | | |
103 | 110 | | |
104 | 111 | | |
| |||
0 commit comments