fix: tree autoExpandParent bug
parent
ee778a2faa
commit
ba9c766f31
|
@ -134,11 +134,15 @@ exports[`renders ./components/tree-select/demo/suffix.vue correctly 1`] = `
|
||||||
exports[`renders ./components/tree-select/demo/tree-line.vue correctly 1`] = `
|
exports[`renders ./components/tree-select/demo/tree-line.vue correctly 1`] = `
|
||||||
<div class="ant-space ant-space-vertical">
|
<div class="ant-space ant-space-vertical">
|
||||||
<div class="ant-space-item" style="margin-bottom: 8px;"><button type="button" role="switch" aria-checked="true" class="ant-switch-checked ant-switch">
|
<div class="ant-space-item" style="margin-bottom: 8px;"><button type="button" role="switch" aria-checked="true" class="ant-switch-checked ant-switch">
|
||||||
<!----><span class="ant-switch-inner">treeLine</span>
|
<div class="ant-switch-handle">
|
||||||
|
<!---->
|
||||||
|
</div><span class="ant-switch-inner">treeLine</span>
|
||||||
</button></div>
|
</button></div>
|
||||||
<!---->
|
<!---->
|
||||||
<div class="ant-space-item" style="margin-bottom: 8px;"><button type="button" role="switch" aria-checked="false" class="ant-switch">
|
<div class="ant-space-item" style="margin-bottom: 8px;"><button type="button" role="switch" aria-checked="false" class="ant-switch">
|
||||||
<!----><span class="ant-switch-inner">showLeafIcon</span>
|
<div class="ant-switch-handle">
|
||||||
|
<!---->
|
||||||
|
</div><span class="ant-switch-inner">showLeafIcon</span>
|
||||||
</button></div>
|
</button></div>
|
||||||
<!---->
|
<!---->
|
||||||
<div class="ant-space-item">
|
<div class="ant-space-item">
|
||||||
|
|
|
@ -304,9 +304,13 @@ exports[`renders ./components/tree/demo/dynamic.vue correctly 1`] = `
|
||||||
exports[`renders ./components/tree/demo/line.vue correctly 1`] = `
|
exports[`renders ./components/tree/demo/line.vue correctly 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<div style="margin-bottom: 16px;"> showLine: <button type="button" role="switch" aria-checked="true" class="ant-switch-checked ant-switch">
|
<div style="margin-bottom: 16px;"> showLine: <button type="button" role="switch" aria-checked="true" class="ant-switch-checked ant-switch">
|
||||||
<!----><span class="ant-switch-inner"><!----></span>
|
<div class="ant-switch-handle">
|
||||||
|
<!---->
|
||||||
|
</div><span class="ant-switch-inner"><!----></span>
|
||||||
</button><br><br> showIcon: <button type="button" role="switch" aria-checked="false" class="ant-switch">
|
</button><br><br> showIcon: <button type="button" role="switch" aria-checked="false" class="ant-switch">
|
||||||
<!----><span class="ant-switch-inner"><!----></span>
|
<div class="ant-switch-handle">
|
||||||
|
<!---->
|
||||||
|
</div><span class="ant-switch-inner"><!----></span>
|
||||||
</button></div>
|
</button></div>
|
||||||
<div role="tree" class="ant-tree ant-tree-icon-hide ant-tree-show-line">
|
<div role="tree" class="ant-tree ant-tree-icon-hide ant-tree-show-line">
|
||||||
<!---->
|
<!---->
|
||||||
|
|
|
@ -25,11 +25,11 @@ import DropIndicator from './DropIndicator';
|
||||||
import {
|
import {
|
||||||
computed,
|
computed,
|
||||||
defineComponent,
|
defineComponent,
|
||||||
onMounted,
|
|
||||||
onUnmounted,
|
onUnmounted,
|
||||||
reactive,
|
reactive,
|
||||||
ref,
|
ref,
|
||||||
shallowRef,
|
shallowRef,
|
||||||
|
watch,
|
||||||
watchEffect,
|
watchEffect,
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import initDefaultProps from '../_util/props-util/initDefaultProps';
|
import initDefaultProps from '../_util/props-util/initDefaultProps';
|
||||||
|
@ -145,15 +145,41 @@ export default defineComponent({
|
||||||
});
|
});
|
||||||
let init = false; // 处理 defaultXxxx api, 仅仅首次有效
|
let init = false; // 处理 defaultXxxx api, 仅仅首次有效
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
init = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
// ================ expandedKeys =================
|
// ================ expandedKeys =================
|
||||||
watchEffect(() => {
|
// watchEffect(() => {
|
||||||
|
// let keys = expandedKeys.value;
|
||||||
|
// // ================ expandedKeys =================
|
||||||
|
// if (props.expandedKeys !== undefined || (init && props.autoExpandParent)) {
|
||||||
|
// keys =
|
||||||
|
// props.autoExpandParent || (!init && props.defaultExpandParent)
|
||||||
|
// ? conductExpandParent(props.expandedKeys, keyEntities.value)
|
||||||
|
// : props.expandedKeys;
|
||||||
|
// } else if (!init && props.defaultExpandAll) {
|
||||||
|
// const cloneKeyEntities = { ...keyEntities.value };
|
||||||
|
// delete cloneKeyEntities[MOTION_KEY];
|
||||||
|
// keys = Object.keys(cloneKeyEntities).map(key => cloneKeyEntities[key].key);
|
||||||
|
// } else if (!init && props.defaultExpandedKeys) {
|
||||||
|
// keys =
|
||||||
|
// props.autoExpandParent || props.defaultExpandParent
|
||||||
|
// ? conductExpandParent(props.defaultExpandedKeys, keyEntities.value)
|
||||||
|
// : props.defaultExpandedKeys;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (keys) {
|
||||||
|
// expandedKeys.value = keys;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[() => props.expandedKeys, () => props.autoExpandParent, keyEntities],
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
([_newKeys, newAutoExpandParent], [_oldKeys, oldAutoExpandParent]) => {
|
||||||
let keys = expandedKeys.value;
|
let keys = expandedKeys.value;
|
||||||
// ================ expandedKeys =================
|
// ================ expandedKeys =================
|
||||||
if (props.expandedKeys !== undefined || (init && props.autoExpandParent)) {
|
if (
|
||||||
|
props.expandedKeys !== undefined ||
|
||||||
|
(init && newAutoExpandParent !== oldAutoExpandParent)
|
||||||
|
) {
|
||||||
keys =
|
keys =
|
||||||
props.autoExpandParent || (!init && props.defaultExpandParent)
|
props.autoExpandParent || (!init && props.defaultExpandParent)
|
||||||
? conductExpandParent(props.expandedKeys, keyEntities.value)
|
? conductExpandParent(props.expandedKeys, keyEntities.value)
|
||||||
|
@ -172,7 +198,10 @@ export default defineComponent({
|
||||||
if (keys) {
|
if (keys) {
|
||||||
expandedKeys.value = keys;
|
expandedKeys.value = keys;
|
||||||
}
|
}
|
||||||
});
|
init = true;
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
// ================ flattenNodes =================
|
// ================ flattenNodes =================
|
||||||
const flattenNodes = computed(() => {
|
const flattenNodes = computed(() => {
|
||||||
|
|
Loading…
Reference in New Issue