Skip to content

Selects with more than 4 explictly typed options always return string values in v-model. #6568

Description

@baubie

Vue version

3.2.38

Link to minimal reproduction

sfc.vuejs.org

Steps to reproduce

I have a simple <select v-model="foo"> setup with 5 options and the values all set to numbers. When there are 4 options, the variable is set to a number type as expected. When there are 5 or more options, the variable is set to a string!

See the example link as a demo with two identical selects other than the number of options.

If you instead define an array and use v-for to create your options, this bug does not appear and you can have 100 options and the value is always a number.

What is expected?

The v-model variable should always be a number and the number of options set shouldn't matter.

What is actually happening?

As soon as more than 4 explicit option tags are present you get a string as the value.

System Info

No response

Any additional comments?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.🐞 bugSomething isn't workinghas workaroundA workaround has been found to avoid the problemscope: compiler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions