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: combobox prevent behavior #1042

Merged
merged 1 commit into from May 7, 2024

Conversation

T-Roc
Copy link
Contributor

@T-Roc T-Roc commented Apr 30, 2024

【原因】
issues 48281 反馈 AutoComplete 点击边缘,下拉框会跳动,经过排查发现是因为 rc-select 在 mode 为 combobox 的时候,没有禁止默认行为,导致内部 Input 会不断的失焦和聚焦,下拉会不断的展开和隐藏。

image

在源码中注释了,combobox 没有阻止默认行为的原因是为解决 issues 37320 即 combobox 禁用状态下,无法选中文字的问题

为了同时解决上面的问题,并且不影响原来的其他逻辑,我添加了禁用状态的限制条件

Copy link

vercel bot commented Apr 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
select ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 7, 2024 1:49am

@yoyo837
Copy link
Member

yoyo837 commented Apr 30, 2024

测试用例覆盖一下

src/Selector/index.tsx Outdated Show resolved Hide resolved
@T-Roc
Copy link
Contributor Author

T-Roc commented May 6, 2024

我已经优化了代码写法,并添加了测试用例,麻烦帮忙看一下

@afc163
Copy link
Member

afc163 commented May 6, 2024

测试用例挂了,看一下

@T-Roc
Copy link
Contributor Author

T-Roc commented May 6, 2024

测试用例挂了,看一下

image

这个错误升级 @testing-library/jest-dom ,testing-library/react 可以解决,我看到在 pr #1044 中做了处理还没合并到主分支,我这边要处理吗?

@afc163
Copy link
Member

afc163 commented May 6, 2024

我合并了 #1044

rebase 一下即可。

@T-Roc
Copy link
Contributor Author

T-Roc commented May 7, 2024

处理好了

it('should not prevent default behavior when mode is combobox and it is disabled', () => {
const preventDefault = jest.fn();
const { container } = render(
<Select mode="combobox" value="1" disabled>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

第二个用例测试单独的 disabled 吧

@afc163 afc163 merged commit 9c7062c into react-component:master May 7, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants