huntabyte / bits-ui

The headless components for Svelte.
https://bits-ui.com
MIT License
953 stars 70 forks source link

Select component submits "undefined" as a string instead of undefined primitive #539

Closed cleytoncarvalho closed 1 month ago

cleytoncarvalho commented 1 month ago

Describe the bug

When the Select component is used within a form and the form is submitted without selecting an option, the value that I get from the form data is a string with the value "undefined" instead of the primitive undefined.

Reproduction

https://stackblitz.com/edit/github-axqayq?file=src%2Froutes%2F%2Bpage.svelte

Logs

No response

System Info

System:
    OS: macOS 14.2.1
    CPU: (8) arm64 Apple M1
    Memory: 44.38 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.asdf/installs/nodejs/20.11.0/bin/node
    Yarn: 1.22.19 - ~/.asdf/installs/nodejs/20.11.0/bin/yarn
    npm: 10.2.4 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 7.22.0 - ~/.asdf/installs/nodejs/20.11.0/bin/pnpm
    bun: 1.0.29 - ~/.asdf/shims/bun
    Watchman: 2023.06.12.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 124.0.6367.119
    Safari: 17.2.1
  npmPackages:
    @sveltejs/kit: ^2.5.7 => 2.5.7 
    bits-ui: ^0.21.4 => 0.21.4 
    svelte: 5.0.0-next.115 => 5.0.0-next.115

Severity

blocking an upgrade

cleytoncarvalho commented 1 month ago

Sorry. Duplicated #426