Skip to content

Checked state bugged in 2.1.7+ when using checkbox :checked="true/false" state with Vuex #4704

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

Closed
FKobus opened this issue Jan 12, 2017 · 8 comments

Comments

@FKobus
Copy link

FKobus commented Jan 12, 2017

Seems fixing the bug from #4521 created a new bug for :checked="" binding when using in combination with vuex states for maintaining checkbox states.

<template>
	<ul>
		<li v-for="option in visibleOptions" :key="option.value">
			<input
				type="checkbox"
				:name="filter.key"
				:value="option.value"
				:checked="inArray(option.value, filter.active)"
				@change="updateFilter">
		</li>
	</ul>
</template>

In this code example is :checked set to true or false whenever it's in the active filter array.
It seems when this component is updated (via vuex) the :checked stated doesn't get's updated like in 2.1.6. In my application is the state managed almost totally by Vuex.

Vue.js version

2.1.7+

Reproduction Link

http://vroom.automotivated.nl/

Howto reproduce

When selecting several checkboxes (like brands) and use your browser back button to fallback to previous states. (it's managed by the popstate event and uses vuex actions to update actively the new state)

What is expected

The checkbox should go on or off depending on the previous action or new current state.

What is actually happening?

Everything get's correctly updated (value wise), except the checkbox isn't honored to update (checked true/false). It keeps in a previous state. When selecting multiple after eachother and navigating back and forward is looks like is off a beat and missing the last changed checkbox.

Code that goes with it:
https://github.com/Automotivated/vroom/blob/master/src/views/elements/filters/Multiple.vue
Full github repo:
https://github.com/Automotivated/vroom/

While reading the docs in Vuex, it seems to be best practise to do it like I did.

When did it work

It worked like a charm in 2.1.6. Seems really that fixing this bug triggered this bug to be created.

@FKobus FKobus changed the title Checked state bugged after #4521 in 2.1.7+ when using checkbox checked state with Vuex Checked state bugged in 2.1.7+ when using checkbox :checked="true/false" state with Vuex Jan 12, 2017
@TheDutchCoder
Copy link

If you select multiple boxes and you keep going back, all the other ones seem to properly update.

Are you sure it's not a bug in your code?

@FKobus
Copy link
Author

FKobus commented Jan 12, 2017

That's what I described in my issue, it seems to skip the last checked checkbox. I ran several tests and my code didn't change since 2.1.6. When running on 2.1.6 it works perfect. Seems that the changes in 2.1.7 (reffered the issue) are causing the problem.

@TheDutchCoder
Copy link

Gotcha, fair enough, I'll leave this to the experts then ;)

@yyx990803
Copy link
Member

Should be a duplicate of #4620 (and fixed via #4639, not released yet)

@FKobus
Copy link
Author

FKobus commented Jan 12, 2017

I runned my code on the dev branch too and the issue remained. Especially because the state doesn't get's updated by the click or change event.

@yyx990803
Copy link
Member

@FKobus did you build the dev branch code?

@FerryKobus
Copy link

@yyx990803 Missed that part. When running it on the new fixes it's behaving as before. Thanks for the response

@ttakahashi2013
Copy link

ttakahashi2013 commented Sep 17, 2017

hi, is this closed in the latest code?
i encountered the same issue.

            <li v-for="dueDateTask in dueDateTasks">
              <input type="checkbox" id="today_check001" class="task_list_check" v-on:click="finish(dueDateTask.id)">
            </li>
      finish(taskId) {
        TaskApi.finish(taskId)
          .then(() => {
            this.getTasks();
          });
      },

program is running after updating record condition, it will read and display all datas again.
but checkbox true/false condition remains even reading new records.
vue version is 3.10.3.

thx,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants