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

[Component] [select]: select 配置可清空功能,清空后值变成undefined,类型发生变化 #16919

Closed
xingyixiang opened this issue May 20, 2024 · 8 comments

Comments

@xingyixiang
Copy link
Contributor

xingyixiang commented May 20, 2024

Bug Type: Component

Environment

  • Vue Version: 3.4.21
  • Element Plus Version: 2.7.3
  • Browser / OS: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
  • Build Tool: Vite

Reproduction

Related Component

  • el-select

Reproduction Link

Element Plus Playground

Steps to reproduce

下拉选择后点击清空按钮

What is Expected?

绑定的值还是string类型,值变成空字符串

What is actually happening?

值变成undefined

Additional comments

@xingyixiang xingyixiang changed the title [Component] [select] [Component] [select]: select 配置可清空功能,清空后值类型变成undefined,类型发生变化 [Component] [select]: select 配置可清空功能,清空后值类型变成undefined,类型发生变化 May 20, 2024
@xingyixiang xingyixiang changed the title [Component] [select]: select 配置可清空功能,清空后值类型变成undefined,类型发生变化 [Component] [select]: select 配置可清空功能,清空后值变成undefined,类型发生变化 May 20, 2024
@warmthsea
Copy link
Contributor

https://github.com/element-plus/element-plus/blob/b1bfb9fd1b52265ffd7737f4e9d81e0ac99c17d6/packages/hooks/use-empty-values/index.ts#L39C1-L51C5

It seems to be here.

@warmthsea
Copy link
Contributor

You can set :value-on-clear

image

@xingyixiang
Copy link
Contributor Author

@warmthsea @kooriookami I understand that the default should be set to an empty string so that there are no breaking changes.

@btea
Copy link
Collaborator

btea commented May 21, 2024

@xingyixiang The current effect should be the same as before 2.7.0. To meet your requirements, configuring value-on-clear as @warmthsea suggested should be enough.

Or did I misunderstand what you meant? 🤔

@warmthsea
Copy link
Contributor

clearable after:

2.56: (<2.60) old value type
2.60: undefined
2.70: undefined (add new attributes :value-on-clear)
🤔

screenshots

@btea
Copy link
Collaborator

btea commented May 21, 2024

An adjustment made intentionally in version 2.6.0. #15995

@xingyixiang
Copy link
Contributor Author

An adjustment made intentionally in version 2.6.0. #15995

If it's a long-term change, so be it.

@huhaoer
Copy link

huhaoer commented Jun 5, 2024

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

No branches or pull requests

4 participants