-
Notifications
You must be signed in to change notification settings - Fork 545
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
Fully controlled form elements #188
base: master
Are you sure you want to change the base?
Conversation
I am a bit confused by this RFC. The basic example says:
I find that untrue, in the following repro only the first char is displayed: The RFC talks about In particular, this includes when v-model updates the source and this is why the sandbox above only displays a single character:
|
Thanks for pointing that out, this shows that current behaviour is inconsistent. For setup it works, for options it does not. But the behaviour should be the same both for setup and options. |
I see, I have never used the options API. Maybe the RFC should be more clear about how v-model works differently in each API and how it's gonna unify them. Currently there's no mention of either. All examples are based on Options API. From my first read I got the impression that it wants to change the way v-model works -- or add alternative ways/mode (e.g. Not trying to challenge the RFC but as a Composition API user I don't quite get it. |
Yes, this is worth mentioning in RFC, I'll update it later accordingly. I didn't mention it beforehand because I was unaware that |
Is it expected than even for setup(), the behavior is different for get/set and computed ? https://codesandbox.io/s/v-model-decomposed-camel-case-5ftt7 |
It is not, thanks for adding that! I'll update RFC later to reflect this inconsistency as well. |
Added a few more examples: Also expanded Composition API section with current inconsistencies. |
I don't think the "fix readonly on checkboxes" motivation is good. Is the code example even working? In this case I think there are cleaner way to "fix HTML". <template>
<input type=checkbox @click="e => { if (readonly) e.preventDefault() }">
</template> What this does is clear and works at lowest level. (If you can, a better option is to use |
A form element should always be controlled because that's how binding works. <input type="text" value="TEXT" /> A developer binds property <input type="text" :value.attr="'TEXT'" /> A developer binds attribute That's how binding works, and so called controlled. This behavior should be constant, and should not change depending on what elements it applies. |
I'm trying to understand the status of this RFC... In the top-level readme it states
Is there such a discussion thread? |
This PR was created before the implementation of GitHub discussions. As far as I know, there's no related Discussion thread, but one could be opened. |
This would be a useful improvement |
Change
v-model
behaviour to be in full control over the displayed value.Rendered RFC