Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Select value not reset after unselect an item #3156

Closed
wong2 opened this issue Jun 1, 2024 · 1 comment · Fixed by #3157
Closed

[BUG] - Select value not reset after unselect an item #3156

wong2 opened this issue Jun 1, 2024 · 1 comment · Fixed by #3157
Assignees
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working

Comments

@wong2
Copy link

wong2 commented Jun 1, 2024

NextUI Version

2.4.1

Describe the bug

In an uncontrolled form, after select and then unselect an item, reading form data inonSubmit still gets the selected value for this field.

Your Example Website or App

const onSubmit = useCallback((e: FormEvent) => {
  e.preventDefault()
  const formData = new FormData(e.target as HTMLFormElement)
  alert(JSON.stringify(Object.fromEntries(formData), null, 2))
}, [])

return (
  <form onSubmit={onSubmit}>
    <Select name="account_filter" label="Account filter" size="sm">
      <SelectItem key="verified">From verified users</SelectItem>
      <SelectItem key="follows">From accounts you follow</SelectItem>
    </Select>
  </form>
)

Steps to Reproduce the Bug or Issue

  1. Select an item in Select
  2. Unselect the item
  3. Submit the form

You can see the process in my video attachment.

Expected behavior

I'd expect to get empty value for this Select field

Screenshots or Videos

Screen.Recording.2024-06-01.at.13.11.47.mov

Operating System Version

macOS

Browser

Chrome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants