|
@@ -199,7 +199,9 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
notifyLoad: (newLoadedKeys: Set<string>, data: BasicTreeNodeData) => void;
|
|
|
updateInputFocus: (bool: boolean) => void;
|
|
|
updateLoadKeys: (data: BasicTreeNodeData, resolve: (value?: any) => void) => void;
|
|
|
- updateIsFocus: (bool: boolean) => void
|
|
|
+ updateIsFocus: (bool: boolean) => void;
|
|
|
+ setClearInputSign: (sign: boolean) => void;
|
|
|
+ getClearInputSign: () => boolean
|
|
|
}
|
|
|
|
|
|
export default class TreeSelectFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TreeSelectAdapter<P, S>, P, S> {
|
|
@@ -588,7 +590,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
const { keyMaps } = this.getProps();
|
|
|
const newExpandedKeys: Set<string> = new Set(expandedKeys);
|
|
|
const isExpandControlled = this._isExpandControlled();
|
|
|
- const expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities);
|
|
|
+ const expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities, false);
|
|
|
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
|
const newFlattenNodes = flattenTreeData(treeData, newExpandedKeys, keyMaps);
|
|
|
|
|
@@ -615,7 +617,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
let newFlattenNodes = [];
|
|
|
let filteredShownKeys = new Set([]);
|
|
|
if (!sugInput) {
|
|
|
- expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities);
|
|
|
+ expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities, false);
|
|
|
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
|
newFlattenNodes = flattenTreeData(treeData, newExpandedKeys, keyMaps);
|
|
|
} else {
|
|
@@ -880,4 +882,30 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
setLoadKeys(data: BasicTreeNodeData, resolve: (value?: any) => void) {
|
|
|
this._adapter.updateLoadKeys(data, resolve);
|
|
|
}
|
|
|
+
|
|
|
+ handlePopoverVisibleChange(isVisible: boolean) {
|
|
|
+ const { filterTreeNode, searchAutoFocus, searchPosition } = this.getProps();
|
|
|
+ const inputValue = this.getState('inputValue');
|
|
|
+ // 将 inputValue 清空,如果有选中值的话,选中项能够快速回显
|
|
|
+ // Clear the inputValue. If there is a selected value, the selected item can be quickly echoed.
|
|
|
+ if (isVisible === false && filterTreeNode) {
|
|
|
+ inputValue && this._adapter.setClearInputSign(true);
|
|
|
+ this.clearInputValue();
|
|
|
+ }
|
|
|
+ if (filterTreeNode && searchPosition === strings.SEARCH_POSITION_DROPDOWN && isVisible && searchAutoFocus) {
|
|
|
+ this.focusInput(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ handleAfterClose() {
|
|
|
+ // flattenNode 的变化将导致弹出层面板中的选项数目变化
|
|
|
+ // 在弹层完全收起之后,再通过 clearInput 重新计算 state 中的 expandedKey, flattenNode
|
|
|
+ // 防止在弹出层未收起时弹层面板中选项数目变化导致视觉上出现弹层闪动问题
|
|
|
+ // Changes to flattenNode will cause the number of options in the popup panel to change
|
|
|
+ // After the pop-up layer is completely closed, recalculate the expandedKey and flattenNode in the state through clearInput.
|
|
|
+ // Prevent the pop-up layer from flickering visually due to changes in the number of options in the pop-up panel when the pop-up layer is not collapsed.
|
|
|
+ const { filterTreeNode } = this.getProps();
|
|
|
+ const shouldClear = this._adapter.getClearInputSign();
|
|
|
+ filterTreeNode && shouldClear && this.clearInput();
|
|
|
+ }
|
|
|
}
|