fix: cascader keydown not work in search #958
parent
a1e180da8c
commit
97167fdb7a
|
@ -9,6 +9,7 @@ import { hasProp, getEvents } from '../_util/props-util';
|
||||||
import BaseMixin from '../_util/BaseMixin';
|
import BaseMixin from '../_util/BaseMixin';
|
||||||
import { cloneElement } from '../_util/vnode';
|
import { cloneElement } from '../_util/vnode';
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
import isEqual from 'lodash-es/isEqual';
|
||||||
|
|
||||||
const BUILT_IN_PLACEMENTS = {
|
const BUILT_IN_PLACEMENTS = {
|
||||||
bottomLeft: {
|
bottomLeft: {
|
||||||
|
@ -134,7 +135,7 @@ export default defineComponent({
|
||||||
const { options = [], sActiveValue = [] } = this;
|
const { options = [], sActiveValue = [] } = this;
|
||||||
const result = arrayTreeFilter(
|
const result = arrayTreeFilter(
|
||||||
options,
|
options,
|
||||||
(o, level) => o[this.getFieldName('value')] === sActiveValue[level],
|
(o, level) => isEqual(o[this.getFieldName('value')], sActiveValue[level]),
|
||||||
{ childrenKeyName: this.getFieldName('children') },
|
{ childrenKeyName: this.getFieldName('children') },
|
||||||
);
|
);
|
||||||
if (result[result.length - 2]) {
|
if (result[result.length - 2]) {
|
||||||
|
@ -145,7 +146,7 @@ export default defineComponent({
|
||||||
getActiveOptions(activeValue) {
|
getActiveOptions(activeValue) {
|
||||||
return arrayTreeFilter(
|
return arrayTreeFilter(
|
||||||
this.options || [],
|
this.options || [],
|
||||||
(o, level) => o[this.getFieldName('value')] === activeValue[level],
|
(o, level) => isEqual(o[this.getFieldName('value')], activeValue[level]),
|
||||||
{ childrenKeyName: this.getFieldName('children') },
|
{ childrenKeyName: this.getFieldName('children') },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -244,7 +245,7 @@ export default defineComponent({
|
||||||
const currentOptions = this.getCurrentLevelOptions();
|
const currentOptions = this.getCurrentLevelOptions();
|
||||||
const currentIndex = currentOptions
|
const currentIndex = currentOptions
|
||||||
.map(o => o[this.getFieldName('value')])
|
.map(o => o[this.getFieldName('value')])
|
||||||
.indexOf(activeValue[currentLevel]);
|
.findIndex(val => isEqual(activeValue[currentLevel], val));
|
||||||
if (
|
if (
|
||||||
e.keyCode !== KeyCode.DOWN &&
|
e.keyCode !== KeyCode.DOWN &&
|
||||||
e.keyCode !== KeyCode.UP &&
|
e.keyCode !== KeyCode.UP &&
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { getComponent, findDOMNode } from '../_util/props-util';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import arrayTreeFilter from 'array-tree-filter';
|
import arrayTreeFilter from 'array-tree-filter';
|
||||||
import BaseMixin from '../_util/BaseMixin';
|
import BaseMixin from '../_util/BaseMixin';
|
||||||
|
import isEqual from 'lodash-es/isEqual';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CascaderMenus',
|
name: 'CascaderMenus',
|
||||||
|
@ -116,7 +117,7 @@ export default {
|
||||||
const options = this.options;
|
const options = this.options;
|
||||||
return arrayTreeFilter(
|
return arrayTreeFilter(
|
||||||
options,
|
options,
|
||||||
(o, level) => o[this.getFieldName('value')] === activeValue[level],
|
(o, level) => isEqual(o[this.getFieldName('value')], activeValue[level]),
|
||||||
{ childrenKeyName: this.getFieldName('children') },
|
{ childrenKeyName: this.getFieldName('children') },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -157,7 +158,7 @@ export default {
|
||||||
|
|
||||||
isActiveOption(option, menuIndex) {
|
isActiveOption(option, menuIndex) {
|
||||||
const { activeValue = [] } = this;
|
const { activeValue = [] } = this;
|
||||||
return activeValue[menuIndex] === option[this.getFieldName('value')];
|
return isEqual(activeValue[menuIndex], option[this.getFieldName('value')]);
|
||||||
},
|
},
|
||||||
saveMenuItem(index) {
|
saveMenuItem(index) {
|
||||||
return node => {
|
return node => {
|
||||||
|
|
Loading…
Reference in New Issue