diff --git a/src/cascader/src/Cascader.vue b/src/cascader/src/Cascader.vue index 4d38af5c4..fe4eb8e5e 100644 --- a/src/cascader/src/Cascader.vue +++ b/src/cascader/src/Cascader.vue @@ -92,7 +92,9 @@ import { warn, call } from '../../_utils' import CascaderMenu from './CascaderMenu.vue' import CascaderSelectMenu from './CascaderSelectMenu.vue' import styles from './styles' +import { depx } from 'seemly' +// TODO refactor cascader menu keyboard scroll (use virtual list) export default { name: 'Cascader', components: { @@ -103,7 +105,15 @@ export default { VTarget, VFollower }, - mixins: [configurable, themeable, locale('Cascader'), withCssr(styles)], + mixins: [ + configurable, + themeable, + locale('Cascader'), + withCssr(styles, { + injectCssrProps: true, + themeKey: 'mergedTheme' + }) + ], provide () { return { NCascader: this @@ -275,9 +285,15 @@ export default { switch (direction) { case 'prev': if (keyboardKey !== null) { - const node = treeMate.getPrev(keyboardKey) + const node = treeMate.getPrev(keyboardKey, { loop: true }) if (node !== null) { updateKeyboardKey(node.key) + this.cascaderMenuRef.submenuRefs[ + node.level + ].scrollbarRef.scrollTo({ + index: node.index, + elSize: depx(this.cssrProps.$local.optionHeight) + }) } } break @@ -286,11 +302,23 @@ export default { const node = treeMate.getFirstAvailableNode() if (node !== null) { updateKeyboardKey(node.key) + this.cascaderMenuRef.submenuRefs[ + node.level + ].scrollbarRef.scrollTo({ + index: node.index, + elSize: depx(this.cssrProps.$local.optionHeight) + }) } } else { - const node = treeMate.getNext(keyboardKey) + const node = treeMate.getNext(keyboardKey, { loop: true }) if (node !== null) { updateKeyboardKey(node.key) + this.cascaderMenuRef.submenuRefs[ + node.level + ].scrollbarRef.scrollTo({ + index: node.index, + elSize: depx(this.cssrProps.$local.optionHeight) + }) } } break diff --git a/src/scrollbar/src/ScrollBar.vue b/src/scrollbar/src/ScrollBar.vue index 3a8cba798..cd4ee220d 100644 --- a/src/scrollbar/src/ScrollBar.vue +++ b/src/scrollbar/src/ScrollBar.vue @@ -335,7 +335,7 @@ export default { behavior ) } else if (index !== undefined && elSize !== undefined) { - this.scrollToPosition(0, index * elSize, behavior, debounce, behavior) + this.scrollToPosition(0, index * elSize, elSize, debounce, behavior) } else if (position === 'bottom') { this.scrollToPosition(0, Number.MAX_SAFE_INTEGER, 0, false, behavior) } else if (position === 'top') {