Skip to content

select({ value: "..." }) does not select default item? #346

@danawoodman

Description

@danawoodman

When rendering a select with a value set, the select does not automatically select the item passed in as value:

function Form() {
  const data = reactive({
    current: "6",
    items: [
      { label: "Item 5", value: "5" },
      { label: "Item 6", value: "6" },
      { label: "Item 7", value: "7" },
    ],
  });
	
  return list(
    select({
      oninput: (e) => (data.current = e.target.value),
      value: () => data.current,
    }),
    data.items,
    (i) => t.option({ value: i.val.value }, i.val.label),
  )
}

To get the items to select, you have to pass selected: data.current === i.val.value in your option.

Is this expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions