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

[Search]回车提交如果已在dataSource里为什么会触发两次onSearch #4049

Closed
xmsz opened this issue Aug 17, 2022 · 4 comments · Fixed by #4524, #4528 or #4530
Closed

[Search]回车提交如果已在dataSource里为什么会触发两次onSearch #4049

xmsz opened this issue Aug 17, 2022 · 4 comments · Fixed by #4524, #4528 or #4530
Assignees
Labels
improvement improve some features 🏗 Need Reproduce A demo(codepen/codesandbox) is needed Next release issues to close in next release

Comments

@xmsz
Copy link

xmsz commented Aug 17, 2022

Component

Search

Feature Description

背景


  <Search
          onSearch={(value) => {
            console.log('search');
          }}
          dataSource={[{labe:"a", value:"a"}]}
        />

用户输入a,然后回车,会触发两次onSearch
触发条件是必须满足value存在于datasource

如果用户输入后,手动点击提交 => 正常
如果用户输入value,但不存在与datasource,回车提交 => 正常

需求

  • 为什么会触发两次
  • 如何避免触发两次
  • 额外 autoHighlightFirstItem 类型不存在
@lakerswgq
Copy link
Contributor

image

只看到一次 onSearch,你升级到最新版本试试

@lakerswgq lakerswgq added the 🏗 Need Reproduce A demo(codepen/codesandbox) is needed label Sep 13, 2022
@xmsz
Copy link
Author

xmsz commented Sep 13, 2022

Search

https://codepen.io/xmsz/pen/wvjzyym

我少打了 需要配合autoHighlightFirstItem={false}复现

@lakerswgq
Copy link
Contributor

第一次是输入框回车触发的,第二次是高亮元素触发的

@xmsz
Copy link
Author

xmsz commented Sep 26, 2022

第一次是输入框回车触发的,第二次是高亮元素触发的

那我改如何避免

@YunMeng99 YunMeng99 added the improvement improve some features label Aug 21, 2023
@YSMJ1994 YSMJ1994 added the Next release issues to close in next release label Nov 10, 2023
@YSMJ1994 YSMJ1994 assigned seven-lh and YunMeng99 and unassigned bindoon and seven-lh Nov 10, 2023
@YunMeng99 YunMeng99 linked a pull request Nov 14, 2023 that will close this issue
YSMJ1994 added a commit that referenced this issue Nov 15, 2023
YSMJ1994 added a commit that referenced this issue Nov 15, 2023
…rstItem=false, close #4049 (#4524)

* fix(Search): onSearch run only once close #4049

* fix(Search): trigger a onsearch event close #4049

* fix(Search): press enter will call onSearch once when autoHighlightFirstItem=false, close #4049

---------

Co-authored-by: 珵之 <chengzhi.zpc@alibaba-inc.com>
YSMJ1994 added a commit that referenced this issue Nov 15, 2023
…hlightFirstItem=false, close #4049 (#4524)"

This reverts commit 1eea155.
@YSMJ1994 YSMJ1994 linked a pull request Nov 15, 2023 that will close this issue
@YSMJ1994 YSMJ1994 reopened this Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement improve some features 🏗 Need Reproduce A demo(codepen/codesandbox) is needed Next release issues to close in next release
Projects
Archived in project
6 participants