naive-ui
naive-ui copied to clipboard
Allow NInput to not trigger useFormItem
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.
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
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- [X] The provided reproduction is a minimal reproducible example of the bug.