Skip to content

Commit f77b801

Browse files
author
Marko Petzold
committed
fix: bind value directly to md-outlined-select for reliable form submission
1 parent af79d68 commit f77b801

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/widget-form.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,16 @@ export class WidgetForm extends LitElement {
248248
}
249249

250250
renderDropdown(field: Column, i: number) {
251+
// Bind the value on the select itself (not just `selected` on the option):
252+
// md-outlined-select only reports its `value` to the form via ElementInternals,
253+
// and the declarative `selected` attribute does not reliably sync into it — so
254+
// a prefilled option would display but submit empty.
251255
return html`
252256
<label class="label">
253257
${field.label}
254258
<md-outlined-select
255259
name="column-${i}"
260+
.value=${field.preFilledValue ?? field.defaultValue ?? ''}
256261
supporting-text=${field.description ?? ''}
257262
?required=${field.required && !field.defaultValue && !field.preFilledValue}
258263
>
@@ -261,10 +266,7 @@ export class WidgetForm extends LitElement {
261266
(val) => val.value,
262267
(val) => {
263268
return html`
264-
<md-select-option
265-
.value="${val.value ?? ''}"
266-
?selected="${val.value === (field.preFilledValue ?? field.defaultValue)}"
267-
>
269+
<md-select-option .value="${val.value ?? ''}">
268270
${val.displayLabel}
269271
</md-select-option>
270272
`

0 commit comments

Comments
 (0)