Skip to content

Change onChange trigger event from change to input for checklist #143

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/fields/core/fieldChecklist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.listbox.form-control(v-if="schema.listBox", :disabled="disabled")
.list-row(v-for="item in items")
label
input(type="checkbox", :checked="getItemIsChecked(item)", :disabled="disabled", @change="onChanged($event, item)")
input(type="checkbox", :checked="getItemIsChecked(item)", :disabled="disabled", @input="onChanged($event, item)")
| {{ getItemName(item) }}

.combobox.form-control(v-if="!schema.listBox", :disabled="disabled")
Expand All @@ -14,7 +14,7 @@
.dropList
.list-row(v-if="comboExpanded", v-for="item in items")
label
input(type="checkbox", :checked="getItemIsChecked(item)", :disabled="disabled", @change="onChanged($event, item)")
input(type="checkbox", :checked="getItemIsChecked(item)", :disabled="disabled", @input="onChanged($event, item)")
| {{ getItemName(item) }}
</template>

Expand Down Expand Up @@ -69,7 +69,7 @@

onChanged(event, item) {
if (isNil(this.value))
this.value = [];
this.$set(this, "value", []);

if (event.target.checked)
this.value.push(this.getItemID(item));
Expand Down
12 changes: 6 additions & 6 deletions test/unit/specs/fields/fieldChecklist.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe("fieldChecklist.vue", function() {

it("model value should be the listbox value if changed", (done) => {
checkboxes[0].checked = true;
trigger(checkboxes[0], "change");
trigger(checkboxes[0], "input");

vm.$nextTick( () => {
expect(model.skills).to.be.deep.equal(["ReactJS", "HTML5"]);
Expand Down Expand Up @@ -142,7 +142,7 @@ describe("fieldChecklist.vue", function() {

it("model value should be the listbox value if changed", (done) => {
checkboxes[0].checked = true;
trigger(checkboxes[0], "change");
trigger(checkboxes[0], "input");

vm.$nextTick( () => {
expect(model.skills).to.be.deep.equal([3, 1]);
Expand Down Expand Up @@ -208,7 +208,7 @@ describe("fieldChecklist.vue", function() {

it("model value should be the listbox value if changed", (done) => {
checkboxes[0].checked = true;
trigger(checkboxes[0], "change");
trigger(checkboxes[0], "input");

vm.$nextTick( () => {
expect(model.skills).to.be.deep.equal([3, 1]);
Expand Down Expand Up @@ -305,7 +305,7 @@ describe("fieldChecklist.vue", function() {

it("model value should be the dropList value if changed (add)", (done) => {
checkboxes[0].checked = true;
trigger(checkboxes[0], "change");
trigger(checkboxes[0], "input");

vm.$nextTick( () => {
expect(model.skills).to.be.deep.equal(["ReactJS", "HTML5"]);
Expand All @@ -316,7 +316,7 @@ describe("fieldChecklist.vue", function() {

it("model value should be the checklist value if changed (remove)", (done) => {
checkboxes[0].checked = false;
trigger(checkboxes[0], "change");
trigger(checkboxes[0], "input");

vm.$nextTick( () => {
expect(model.skills).to.be.deep.equal(["ReactJS"]);
Expand All @@ -328,7 +328,7 @@ describe("fieldChecklist.vue", function() {
it("model value should be the dropList value if changed (null)", (done) => {
model.skills = null;
checkboxes[0].checked = true;
trigger(checkboxes[0], "change");
trigger(checkboxes[0], "input");

vm.$nextTick( () => {
expect(model.skills).to.be.deep.equal(["HTML5"]);
Expand Down