fix(basic-tree): `checkedKeys` not worked with `search`
修复搜索功能可能导致`checkedKeys`丢失的问题 fixed: #915
This commit is contained in:
parent
1b3058f825
commit
b06a7ab77b
|
|
@ -8,15 +8,15 @@
|
||||||
|
|
||||||
### 🐛 Bug Fixes
|
### 🐛 Bug Fixes
|
||||||
|
|
||||||
- **Table**
|
- **BasicTable**
|
||||||
- 修复滚动条样式问题
|
- 修复滚动条样式问题(移除了滚动样式补丁)
|
||||||
- 修复树形表格的带有展开图标的单元格的内容对齐问题
|
- 修复树形表格的带有展开图标的单元格的内容对齐问题
|
||||||
- 新增`headerTop`插槽
|
- 新增`headerTop`插槽
|
||||||
- 修复操作列的按钮在 disabled 状态下的颜色显示
|
- 修复操作列的按钮在 disabled 状态下的颜色显示
|
||||||
- **AppSearch** 修复可能会搜索隐藏菜单的问题
|
|
||||||
- **TableAction**
|
- **TableAction**
|
||||||
- 仅在 action.tooltip 存在的情况下 才包裹 Tooltip 组件
|
- 仅在 `action.tooltip`存在的情况下 才创建 Tooltip 组件
|
||||||
- 修复组件内的圆形按钮内容没有居中的问题
|
- 修复组件内的圆形按钮内容没有居中的问题
|
||||||
|
- **AppSearch** 修复可能会搜索隐藏菜单的问题
|
||||||
- **BasicUpload** 修复处理非`array`值时报错的问题
|
- **BasicUpload** 修复处理非`array`值时报错的问题
|
||||||
- **Form** 修复`FormItem`的`suffix`插槽样式问题
|
- **Form** 修复`FormItem`的`suffix`插槽样式问题
|
||||||
- **Menu**
|
- **Menu**
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
- **Markdown** 修复初始化异常以及不能正确地动态设置 value 的问题
|
- **Markdown** 修复初始化异常以及不能正确地动态设置 value 的问题
|
||||||
- **Modal** 确保 props 正确被传递
|
- **Modal** 确保 props 正确被传递
|
||||||
- **MultipleTab** 修复可能会意外创建登录路由标签的问题
|
- **MultipleTab** 修复可能会意外创建登录路由标签的问题
|
||||||
|
- **BasicTree** 修复搜索功能可能导致`checkedKeys`丢失的问题
|
||||||
- **其它**
|
- **其它**
|
||||||
- 修复菜单默认折叠的配置不起作用的问题
|
- 修复菜单默认折叠的配置不起作用的问题
|
||||||
- 修复`safari`浏览器报错导致网站打不开
|
- 修复`safari`浏览器报错导致网站打不开
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
import TreeHeader from './TreeHeader.vue';
|
import TreeHeader from './TreeHeader.vue';
|
||||||
import { ScrollContainer } from '/@/components/Container';
|
import { ScrollContainer } from '/@/components/Container';
|
||||||
|
|
||||||
import { omit, get } from 'lodash-es';
|
import { omit, get, cloneDeep, concat, uniq } from 'lodash-es';
|
||||||
import { isBoolean, isFunction } from '/@/utils/is';
|
import { isBoolean, isFunction } from '/@/utils/is';
|
||||||
import { extendSlots, getSlot } from '/@/utils/helper/tsxHelper';
|
import { extendSlots, getSlot } from '/@/utils/helper/tsxHelper';
|
||||||
import { filter } from '/@/utils/helper/treeHelper';
|
import { filter } from '/@/utils/helper/treeHelper';
|
||||||
|
|
@ -56,6 +56,25 @@
|
||||||
searchData: [] as TreeItem[],
|
searchData: [] as TreeItem[],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const copyState = {
|
||||||
|
checkedKeys: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => searchState.startSearch,
|
||||||
|
(newVal, oldVal) => {
|
||||||
|
if (newVal && !oldVal) {
|
||||||
|
// before search, save current checkedKeys
|
||||||
|
copyState.checkedKeys = cloneDeep(state.checkedKeys);
|
||||||
|
} else if (!newVal && oldVal) {
|
||||||
|
// after search, restore checkedKeys
|
||||||
|
state.checkedKeys = uniq(concat(state.checkedKeys, copyState.checkedKeys));
|
||||||
|
copyState.checkedKeys = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
const treeDataRef = ref<TreeItem[]>([]);
|
const treeDataRef = ref<TreeItem[]>([]);
|
||||||
|
|
||||||
const [createContextMenu] = useContextMenu();
|
const [createContextMenu] = useContextMenu();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue