Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [TreeSelect] In single-selection search, after selecting a item, its child items will be expanded and Popover will be closed immediately (#78) #96

Merged
merged 1 commit into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions packages/semi-foundation/treeSelect/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,6 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
return this.getProp('expandedKeys');
}

_isFilterable() {
return Boolean(this.getProp('filterTreeNode')); // filter can be boolean or function
}

_isSelectToClose() {
return !this.getProp('expandAction');
}
Expand Down Expand Up @@ -402,9 +398,6 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
this._adapter.closeMenu();
this._adapter.unregisterClickOutsideHandler();
this._notifyBlur(e);
if (this._isFilterable()) {
this.clearInput();
}
if (this.getProp('motionExpand')) {
this._adapter.updateState({ motionKeys: new Set([]) } as any);
}
Expand Down
9 changes: 9 additions & 0 deletions packages/semi-ui/treeSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,14 @@ class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState> {
return key;
};

/* Event handler function after popover is closed */
handlePopoverClose = isVisible => {
const { filterTreeNode } = this.props;
if (isVisible === false && Boolean(filterTreeNode)) {
this.foundation.clearInput();
}
}

renderTreeNode = (treeNode: FlattenNode, ind: number, style: React.CSSProperties) => {
const { data } = treeNode;
// eslint-disable-next-line @typescript-eslint/no-shadow
Expand Down Expand Up @@ -1281,6 +1289,7 @@ class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState> {
autoAdjustOverflow={autoAdjustOverflow}
mouseLeaveDelay={mouseLeaveDelay}
mouseEnterDelay={mouseEnterDelay}
onVisibleChange={this.handlePopoverClose}
>
{selection}
</Popover>
Expand Down