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

feat(select): allows select the behavior of triggering blur event in … #962

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yuanxin518
Copy link

@yuanxin518 yuanxin518 commented Jul 20, 2023

select组件,mode="tags"时候,任意输入文字,失去焦点自动生成了tag

新增:
增加配置项 tagsModeCommitOnBlurpreventCommitOnBlur,默认值为true。

功能:
默认情况下,处于tags模式下的select框在输入文字后失去焦点的时候会默认的submit,结果就是生成一个新的tag并记录tag。参考上述提供的issue,提供 tagsModeCommitOnBlur preventCommitOnBlur来实现当此配置的valuefalse true 的时候,失去焦点不默认触发submit 在任何模式下失去焦点的时候都会阻止submit行为,也就是不生成一个新的标签并且不记录,只有当点击候选框中的标签的时候才会生成。

@vercel
Copy link

vercel bot commented Jul 20, 2023

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

Name Status Preview Comments Updated (UTC)
select ❌ Failed (Inspect) Jul 20, 2023 1:47pm

src/Select.tsx Outdated
@@ -198,6 +201,9 @@ const Select = React.forwardRef(
labelInValue,
onChange,

// Blur
tagsModeCommitOnBlur = true,
Copy link
Member

Choose a reason for hiding this comment

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

这样加 API 感觉就过于零碎了...

Copy link
Author

Choose a reason for hiding this comment

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

这样加 API 感觉就过于零碎了...

是不是因为针对tags的模式有点过于零碎? 或许可以提供一个配置,来取消所有模式下的这个失焦行为?

Copy link
Author

Choose a reason for hiding this comment

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

这样加 API 感觉就过于零碎了...

是不是因为针对tags的模式有点过于零碎? 或许可以提供一个配置,来取消所有模式下的这个失焦行为?

就是我觉得,例如对于multiple的模式,支持设置 失焦自动提交 就是说multiple实际支持这个行为,但是现在的情况是这个模式并不支持,所以会有一定的误导。暂时还没想到有更合适的方式来设置这个api。

Copy link
Member

Choose a reason for hiding this comment

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

Tags 模式本身设计就是带着一些交互逻辑的,如果是不需要这个逻辑 HOC multiple 实现一个 Tags 其实也不难。最关键的是,从设计上看其实是希望使用这个交互的,所以我在想这个 API 的必要性。

Copy link
Author

Choose a reason for hiding this comment

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

Tags 模式本身设计就是带着一些交互逻辑的,如果是不需要这个逻辑 HOC multiple 实现一个 Tags 其实也不难。最关键的是,从设计上看其实是希望使用这个交互的,所以我在想这个 API 的必要性。

好的,如果确实考虑到没有必要性,那就麻烦您到时候关一下PR了。在最新的提交里面是把针对tags的改成了针对所有模式的,考虑到后续有新增的不同于tags的默认交互逻辑的模式,我个人觉得这样是合理一点的,。

@yuanxin518
Copy link
Author

yuanxin518 commented Jul 20, 2023

preventCommitOnBlur的Api形式,默认为false,当设置为true的时候,失焦不会触发commit行为

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

2 participants