Skip to content

Combobox example for SolidJS is broken (render is different from state) #1322

Answered by segunadebayo
knpwrs asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @knpwrs,

This is not a bug. Here's the correct set up for the combobox machine:

  const [state, send] = useMachine(
    combobox.machine({
      id: createUniqueId(),
      onOpenChange() {
        setOptions(comboboxData);
      },
      onInputValueChange({ value }) {
        const filtered = comboboxData.filter((item) =>
          item.label.toLowerCase().includes(value.toLowerCase())
        );
        setOptions(filtered.length > 0 ? filtered : comboboxData);
      },
      openOnClick: true,
      multiple: true,
    }),
   // this was missing
    {
      context: createMemo(() => ({
        collection: collection(),
      })),
    }
  );

https://stackblitz.com/edit/solidjs-templ…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by segunadebayo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1321 on March 05, 2024 10:22.