Skip to content

InputMenu: error if field field is nullish or non-string #4509

@hanneskuettner

Description

@hanneskuettner

Environment

N/A

Is this bug related to Nuxt or Vue?

Nuxt

Version

v3.2.0

Reproduction

https://codesandbox.io/p/devbox/compassionate-jasper-w2k3lm

Description

The InputMenu component throws an error if one of the fields provided in filterFields resolved to a nullish or non-string value. You can reproduce this in the sandbox by typing in the input box and observing the console.

So having the following setup errors out, which is a real-world use case I'm encountering this:

<script lang="ts" setup>
const items = [
  {
    label: 'foo',
    alias: 'something'
  },
  {
    label: 'bar'
  }
]
</script>

<template>
  <UInputMenu :items :filter-fields="['label', 'alias']" />
</template>

This is caused by useFilter.contains being called with a non-string value.

It is somewhat related to #3606 which has been addressed previously, but only for primitive item types.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingv3#1289

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions