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(pro:search): empty input segment should be invalid #1494

Merged

Conversation

sallerli1
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added/updated or not needed
  • Docs and demo have been added/updated or not needed

What is the current behavior?

input类型搜索项,先输入,再退格清除,此时空的输入会被校验为合法

What is the new behavior?

修复以上问题,空字符串一律返回 undefined

Other information

@idux-bot
Copy link

idux-bot bot commented Mar 6, 2023

This preview will be available after the AzureCI is passed.

@@ -19,7 +19,7 @@ export function createInputSegment(prefixCls: string, searchField: InputSearchFi
inputClassName: [inputClassName, `${prefixCls}-input-segment-input`],
placeholder: searchField.placeholder,
defaultValue,
parse: input => input,
parse: input => (input ? input : undefined),
format: value => (trim ? value?.trim() : value) ?? '',
}
}
Copy link

Choose a reason for hiding this comment

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

the code review

The code patch looks good. It appears that the goal is to make the input value type of the createInputSegment function to a string or undefined instead of just a string.

The changes check that the input value is not null or undefined before parsing and formatting it, and they also change the return type of the createInputSegment function to string or undefined. This should help prevent any bugs related to unexpected input values.

However, it is worth noting that the parse and format functions are still expecting a string value, so further checks may be necessary if other data types are being used. Additionally, it would be helpful to add more detailed comments to the code explaining what it does and why.

@codecov
Copy link

codecov bot commented Mar 6, 2023

Codecov Report

Merging #1494 (3421b76) into main (1be87e8) will not change coverage.
The diff coverage is n/a.

❗ Current head 3421b76 differs from pull request most recent head fff3012. Consider uploading reports for the commit fff3012 to get more accurate results

@@           Coverage Diff           @@
##             main    #1494   +/-   ##
=======================================
  Coverage   92.73%   92.73%           
=======================================
  Files         331      331           
  Lines       30752    30752           
  Branches     3533     3533           
=======================================
  Hits        28519    28519           
  Misses       2233     2233           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@danranVm danranVm merged commit 168620e into IDuxFE:main Mar 7, 2023
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