Tabs 的 Search 按 enter 提交表达关闭

Change-Id: I810450dbe045c1304fb24a028ec0058178453c21
This commit is contained in:
2betop 2020-11-19 17:43:53 +08:00
parent b06d5524e3
commit d706413ec0
2 changed files with 10 additions and 2 deletions

View File

@ -74,7 +74,7 @@ export class SearchBox extends React.Component<SearchBoxProps> {
}
@autobind
handleKeyUp(e: React.KeyboardEvent<any>) {
handleKeyDown(e: React.KeyboardEvent<any>) {
if (e.key === 'Enter') {
this.handleSearch();
e.preventDefault();
@ -110,7 +110,7 @@ export class SearchBox extends React.Component<SearchBoxProps> {
placeholder={__(placeholder || '输入关键字')}
ref={this.inputRef}
autoComplete="off"
onKeyUp={this.handleKeyUp}
onKeyDown={this.handleKeyDown}
/>
{!mini ? (

View File

@ -129,6 +129,13 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
onChange && onChange([]);
}
@autobind
handleSearchKeyDown(e: React.KeyboardEvent<any>) {
if (e.key === 'Enter') {
e.preventDefault();
}
}
@autobind
handleSearch(text: string) {
// text 有值的时候,走搜索否则直接走 handleSeachCancel ,等同于右侧的 clear 按钮
@ -243,6 +250,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
onChange={this.handleSearch}
placeholder={__('请输入关键字')}
clearable={false}
onKeyDown={this.handleSearchKeyDown}
>
{this.state.searchResult !== null ? (
<a onClick={this.handleSeachCancel}>