From 8478b7382a90e54bf99f63d5841e54f5a6ca77ac Mon Sep 17 00:00:00 2001 From: rickcole Date: Thu, 10 Sep 2020 15:07:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=80=E4=B8=8Btransfer?= =?UTF-8?q?=E7=9A=84=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Transfer.tsx | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/components/Transfer.tsx b/src/components/Transfer.tsx index dd0fe7bb5..05300f290 100644 --- a/src/components/Transfer.tsx +++ b/src/components/Transfer.tsx @@ -131,16 +131,21 @@ export class Transfer extends React.Component { @autobind handleSearch(text: string) { - this.setState( - { - inputValue: text - }, - () => { - // 如果有取消搜索,先取消掉。 - this.cancelSearch && this.cancelSearch(); - this.lazySearch(text); - } - ); + // text 有值的时候,走搜索否则直接走 handleSeachCancel ,等同于右侧的 clear 按钮 + if (text) { + this.setState( + { + inputValue: text + }, + () => { + // 如果有取消搜索,先取消掉。 + this.cancelSearch && this.cancelSearch(); + this.lazySearch(text); + } + ); + } else { + this.handleSeachCancel(); + } } @autobind