Skip to content

Commit 97167fd

Browse files
committed
fix: cascader keydown not work in search #958
1 parent a1e180d commit 97167fd

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

components/vc-cascader/Cascader.jsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { hasProp, getEvents } from '../_util/props-util';
99
import BaseMixin from '../_util/BaseMixin';
1010
import { cloneElement } from '../_util/vnode';
1111
import { defineComponent } from 'vue';
12+
import isEqual from 'lodash-es/isEqual';
1213

1314
const BUILT_IN_PLACEMENTS = {
1415
bottomLeft: {
@@ -134,7 +135,7 @@ export default defineComponent({
134135
const { options = [], sActiveValue = [] } = this;
135136
const result = arrayTreeFilter(
136137
options,
137-
(o, level) => o[this.getFieldName('value')] === sActiveValue[level],
138+
(o, level) => isEqual(o[this.getFieldName('value')], sActiveValue[level]),
138139
{ childrenKeyName: this.getFieldName('children') },
139140
);
140141
if (result[result.length - 2]) {
@@ -145,7 +146,7 @@ export default defineComponent({
145146
getActiveOptions(activeValue) {
146147
return arrayTreeFilter(
147148
this.options || [],
148-
(o, level) => o[this.getFieldName('value')] === activeValue[level],
149+
(o, level) => isEqual(o[this.getFieldName('value')], activeValue[level]),
149150
{ childrenKeyName: this.getFieldName('children') },
150151
);
151152
},
@@ -244,7 +245,7 @@ export default defineComponent({
244245
const currentOptions = this.getCurrentLevelOptions();
245246
const currentIndex = currentOptions
246247
.map(o => o[this.getFieldName('value')])
247-
.indexOf(activeValue[currentLevel]);
248+
.findIndex(val => isEqual(activeValue[currentLevel], val));
248249
if (
249250
e.keyCode !== KeyCode.DOWN &&
250251
e.keyCode !== KeyCode.UP &&

components/vc-cascader/Menus.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { getComponent, findDOMNode } from '../_util/props-util';
22
import PropTypes from '../_util/vue-types';
33
import arrayTreeFilter from 'array-tree-filter';
44
import BaseMixin from '../_util/BaseMixin';
5+
import isEqual from 'lodash-es/isEqual';
56

67
export default {
78
name: 'CascaderMenus',
@@ -116,7 +117,7 @@ export default {
116117
const options = this.options;
117118
return arrayTreeFilter(
118119
options,
119-
(o, level) => o[this.getFieldName('value')] === activeValue[level],
120+
(o, level) => isEqual(o[this.getFieldName('value')], activeValue[level]),
120121
{ childrenKeyName: this.getFieldName('children') },
121122
);
122123
},
@@ -157,7 +158,7 @@ export default {
157158

158159
isActiveOption(option, menuIndex) {
159160
const { activeValue = [] } = this;
160-
return activeValue[menuIndex] === option[this.getFieldName('value')];
161+
return isEqual(activeValue[menuIndex], option[this.getFieldName('value')]);
161162
},
162163
saveMenuItem(index) {
163164
return node => {

0 commit comments

Comments
 (0)