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): segmentState should init only when item key changes #1496

Merged
merged 1 commit into from Mar 11, 2023

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?

searchItem的内容变化后,输入状态内容被初始化

What is the new behavior?

仅当searchItem的key变化后才初始化输入状态,并建立对该key对应的searchState的监听

Other information

if (searchItem?.key === oldSearchItem?.key) {
return
}

searchStateWatchStop?.()
initSegmentStates()
if (searchItem?.key) {
Copy link

Choose a reason for hiding this comment

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

This code looks good and there are no obvious bugs or issues. However, it is always a good idea to do some basic code review to make sure that the code is correct and does not have any potential problems.

First, I would suggest verifying that the searchItem and oldSearchItem variables are defined and not null before comparing them. This can be done by adding a simple check like:

if (searchItem && oldSearchItem && searchItem?.key === oldSearchItem?.key) {
    return;
}

Also, I would recommend adding some logging around the code patch, so we can see what is happening while the code is running. This can help in debugging any issues that may arise.

Finally, I would suggest adding some unit tests to ensure that the code is functioning correctly. This can be done using a testing framework such as Jest.

Overall, this code looks good and should be safe to use. However, it is always a good idea to double check and make sure that the code is correct and does not have any potential issues.

@idux-bot
Copy link

idux-bot bot commented Mar 7, 2023

This preview will be available after the AzureCI is passed.

@codecov
Copy link

codecov bot commented Mar 7, 2023

Codecov Report

Merging #1496 (6744fd0) into main (c217da6) will not change coverage.
The diff coverage is n/a.

❗ Current head 6744fd0 differs from pull request most recent head d953cdf. Consider uploading reports for the commit d953cdf to get more accurate results

@@           Coverage Diff           @@
##             main    #1496   +/-   ##
=======================================
  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 70f947c into IDuxFE:main Mar 11, 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