Skip to content

Passing a dynamic reference to an :is-multi=true select throws error on undefined #212

@tomvanvegchel

Description

@tomvanvegchel

Im working on a codebase that is essentially completely dynamic. To give a short tldr. I am migrating from vue-select to vue3-select-component due to the vue2 -> vue3 migration.

Context on this dynamic code:

  • Tables are generated based on a config
  • Table headers contain filters
  • Each filter is a vue3-select-component with a dynamic reference in the v-model to the column filter value
  • The column filter value will be set on input, this means that the reference to this column filter value if empty can be undefined.
<component
    v-model="filter.columnFilters[column.filter]"
    :is="column.component + 'Select'"
    :ref="column.component + 'Select'"
    :column="column"
    :placeholder="$tc(column.title)"
    :is-multi="column.multiSelect"
    :is-column-filter="true"
/>

This was never an issue on vue-select and still doesn't cause issues in vue3-select-component except for the fact that it throws a console.error on a console.warning which in my eyes is invalid.

  return Array.isArray(n.value) || console.warn(`[vue3-select-component warn]: The v-model provided should be an array when using \`isMulti\` prop, instead it was: ${n.value}`), n.value.map(
    (o) => t.options.find((s) => s.value === o)
  );

Is there a possibility to add an additional check on this map function? This warning is saying the v-model should be an array and then does a map on a value that is not an array?
Would love to keep using this package as it made migrating quite easy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions