From 305801e37fe6cec0ec75f86f23bd056827a337d6 Mon Sep 17 00:00:00 2001 From: Jeff Sagal Date: Fri, 13 Sep 2019 15:28:33 -0700 Subject: [PATCH 1/2] support falsey values with reduce (#939) --- src/components/Select.vue | 2 +- tests/unit/Reduce.spec.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/Select.vue b/src/components/Select.vue index ae2379e..4aa5351 100644 --- a/src/components/Select.vue +++ b/src/components/Select.vue @@ -508,7 +508,7 @@ created() { this.mutableLoading = this.loading; - if (this.value && this.isTrackingValues) { + if (this.value !== null && this.isTrackingValues) { this.setInternalValueFromOptions(this.value) } diff --git a/tests/unit/Reduce.spec.js b/tests/unit/Reduce.spec.js index d4d504f..6d9d288 100755 --- a/tests/unit/Reduce.spec.js +++ b/tests/unit/Reduce.spec.js @@ -152,6 +152,20 @@ describe("When reduce prop is defined", () => { ); }); + it('can work with falsey values', () => { + const option = {value: 0, label: 'No'}; + const Select = shallowMount(VueSelect, { + propsData: { + reduce: option => option.value, + options: [option, {value: 1, label: 'Yes'}], + value: 0, + }, + }); + + expect(Select.vm.findOptionFromReducedValue(option)).toEqual(option); + expect(Select.vm.selectedValue).toEqual([option]); + }); + describe("And when a reduced option is a nested object", () => { it("can determine if an object is pre-selected", () => { const nestedOption = { value: { nested: true }, label: "foo" }; From aecbde83433a72073f8a1cba509a9735846fc626 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 14 Sep 2019 08:01:37 +0930 Subject: [PATCH 2/2] Fix dropdown-toggle not being registered correctly as a mousedown target (#934) --- src/components/Select.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Select.vue b/src/components/Select.vue index 4aa5351..1d5d2be 100644 --- a/src/components/Select.vue +++ b/src/components/Select.vue @@ -619,7 +619,7 @@ const toggleTargets = [ this.$el, this.searchEl, - this.$refs.toggle.$el, + this.$refs.toggle, ]; if (typeof this.$refs.openIndicator !== 'undefined') {