naive-ui icon indicating copy to clipboard operation
naive-ui copied to clipboard

Allow NInput to not trigger useFormItem

Open iamiota opened this issue 10 months ago • 0 comments

Describe the bug

I have a custom Popover component that consists of a NInput search box and a list. When I use it within an NFormItem, the NInput inside the Popover triggers useFormItem , inheriting the validation state of NFormItem. When the Popover disappears, it triggers onBeforeUnmount due to the FormItem, resetting the validation state of NFormItem. I would like to add a prop to NInput to control whether useFormItem is called internally.

image

https://github.com/tusen-ai/naive-ui/assets/7531576/b828ee49-52d2-41d9-b953-cc9d8bcb3be8

Steps to reproduce

<NFormItem>
  <NPopover>
    <NInput placeholder="search" />
    <ul>
      <li>Select one</li>
      <li>Select two</li>
    </ul>
    <template #trigger>
      <p>Select an item</p>
    </template>
  </NPopover>
</NFormItem>

Link to minimal reproduction

https://codesandbox.io/p/devbox/nice-kare-jhpfts

System Info

naive-ui 2.38.1

Used Package Manager

yarn

Validations

iamiota avatar Apr 11 '24 23:04 iamiota