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

The forced local update from a defineModel setter results in unexpected input field values #12265

Open
steven-klein opened this issue Oct 25, 2024 · 1 comment

Comments

@steven-klein
Copy link

steven-klein commented Oct 25, 2024

Vue version

3.4.32+

Link to minimal reproduction

https://play.vuejs.org/#eNqFUslu2zAQ/ZUBL5IBRwKanlzZQFPkkAJd0OZWFoUgj1SmFElwUVwI+vcMKctZEDgnie/N8mbmjeyjMcUQkG1Y5RorjAeHPhiQteq2nHnH2Y4r0RttPYxgsYUJWqt7yCgtO1FXtcMbZYI/kkV5QmL97ANXXDVaOQ8ihW1jrTzLVlxV5dyaGtHDY29k7ZFeAJXZ3f43CDX0QXpxca/tHoZaBtxUpZlDHlsPF73eoyy8FT2JT404g3IpNY7H5tM0Z1flk25sTeOSxFZ0xZ3TinYyxkTOGt0bIdF+M17QCJxtIDGRq6XU958T5m3A9YI3f7H59wp+5w4R4+y7RYd2QM5OnK9th6Q40tc/v+KB/k8kjRYkRZ8hf6DTMkSNc9hVUHuS/SQuqb1JJxOqu3XXB4/KLUNFoTFySvGc0eE+nRn9Ue5l8T7lcTXRFp9d/g1nzZb4le62Bvq432SNPbZC4ZcIVo6uqbp17EdnpaQ8CaBiG8iHFWx3iyLRQh4rpPuvFhTIaD5YBUPCczJcBEnr/LOwywDnDUk+mi109BpNkr5kM09GjYOlyyTTvbTXnwFtXDbthDZWXL5j0wNI2SpB

Steps to reproduce

Use defineModel with a modifier like trim applied in the set transformer. Bind the model to a text input and type a multi-word value into the input.

What is expected?

The trim modifier syncs the trimmed value back to the parent without updating the value attribute on the input.

What is actually happening?

The input value is also updated to the trimmed value, which prevents a user from adding spaces.

System Info

No response

Any additional comments?

Looking at commit de174e1 this may now be the expected behavior, but is a bit unintuitive given how v-model modifiers have worked in the past.

The documentation on modifiers and transformers appears to suggest that you should be able to apply a trim modifier in this manner.

@edison1105 edison1105 added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: defineModel labels Oct 28, 2024
@edison1105
Copy link
Member

a workaround

<input v-model.lazy="model" type="text" />

see Playground

@edison1105 edison1105 added 🔩 p2-edge-case and removed 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants