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

Text in select box with v-model (most of the time) does not update, but value does #8603

Closed
jcat4 opened this issue Aug 3, 2018 · 9 comments

Comments

@jcat4
Copy link

jcat4 commented Aug 3, 2018

Version

2.5.17

Reproduction link

https://jsfiddle.net/jcatfour/g6ykuwhe/

Steps to reproduce

Try to change the dropdown value. The text displayed in the select box will almost always stay as "Today", despite the value changing, though it SOMETIMES will actually change to the correct value. Again, as you can see, the actual value is indeed changing even if the select box does not show it.

What is expected?

The options in the select are based on an array of value pairs, (text, val). The text is what should be shown in the select, and the val is what should be actually passed and stored in the data object. I expect the text to change as well as the value when selecting an option.

What is actually happening?

The value changes every time, but the text mostly stays unchanged, BUT the text does very rarely change as expected.


If this were CONSISTENTLY showing the wrong text with the right value, I would assume that I am just doing something wrong, but since it's infrequent, I'm now not so sure. I would not be surprised if I was doing something wrong. I am going insane, please be my savior.

@jcat4
Copy link
Author

jcat4 commented Aug 3, 2018

Apologies, one last thing: If I have a literal object array in the component's data object, then it seems to work fine. If I use a store or a mixin or anything like that to retrieve an object array, this issue persists.

@posva
Copy link
Member

posva commented Aug 3, 2018

Don't use this in template, just do getDates

@posva posva closed this as completed Aug 3, 2018
@jcat4
Copy link
Author

jcat4 commented Aug 3, 2018

That doesn't fix the problem, though...

https://jsfiddle.net/jcatfour/32xea1bL/

@posva
Copy link
Member

posva commented Aug 3, 2018

So the problem comes from looseEqual comparing plain objects, Dates are not compared correctly and it looks like they are all the same (using that function) so the first option is always the one selected. You can, however, pass the whole object as the value to the option.

@posva posva reopened this Aug 3, 2018
@jcat4
Copy link
Author

jcat4 commented Aug 3, 2018

Hmm, okay, yeah. Binding item instead of item.val to the options works. Is looseEqual something that's in Vue's source, or a JS thing? How'd ya figure it out? I was going insane over this!!

Edit: Just checked the source. Yep, it's there.

Thanks, dude!!

@posva
Copy link
Member

posva commented Aug 4, 2018

I'm not sure this is intentional, I'll come back once I know 🙂

@KaelWD
Copy link
Contributor

KaelWD commented Aug 5, 2018

vuetifyjs/vuetify#4638 😛

@zzuligy
Copy link

zzuligy commented Aug 6, 2018

the loosEqual implementation had defect.
if as comment check two object have the same shape.

a = {x:1},b={x:2} should looseEqual, but it's not.

so looseEqual is not consistent.

for the model directive, when the value is type of the regexes, sets,maps,array buffers,typed arrays etc,there will be a insane.

so, the implementation of looseEqual must think twice.(the acurate version will be more complex)

@posva
Copy link
Member

posva commented Aug 7, 2018

This is actually a duplicate of #7928 and I already submitted a PR for it 😆

@posva posva closed this as completed Aug 7, 2018
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

4 participants