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 searchBar onClear #1721 #1731

Merged
merged 4 commits into from
Aug 28, 2017
Merged

fix searchBar onClear #1721 #1731

merged 4 commits into from
Aug 28, 2017

Conversation

pingan1927
Copy link
Contributor

@pingan1927 pingan1927 commented Aug 23, 2017

First of all, thank you for your contribution! :-)

Please makes sure that these checkboxes are checked before submitting your PR, thank you!

  • Make sure that you follow antd's code convention.
  • Run npm run lint and fix those errors before submitting in order to keep consistent code style.
  • Rebase before creating a PR to keep commit history clear.
  • Add some descriptions and refer relative issues for you PR.

Extra checklist:

if isBugFix :

  • Make sure that you add at least one unit test for the bug which you had fixed.

elif isNewFeature :

  • Update API docs for the component.
  • Update/Add demo to demonstrate new feature.
  • Update TypeScript definition for the component.
  • Add unit tests for the feature.

This change is Reviewable

@pingan1927 pingan1927 requested a review from warmhug August 23, 2017 12:38
@codecov
Copy link

codecov bot commented Aug 23, 2017

Codecov Report

Merging #1731 into 1.x will decrease coverage by 0.02%.
The diff coverage is 28.57%.

Impacted file tree graph

@@            Coverage Diff            @@
##             1.x    #1731      +/-   ##
=========================================
- Coverage   66.2%   66.17%   -0.03%     
=========================================
  Files        228      228              
  Lines       4438     4440       +2     
  Branches    1159     1160       +1     
=========================================
  Hits        2938     2938              
- Misses      1499     1501       +2     
  Partials       1        1
Flag Coverage Δ
#rn 65.43% <ø> (ø) ⬆️
#web 66.87% <28.57%> (-0.06%) ⬇️
Impacted Files Coverage Δ
components/search-bar/index.web.tsx 75.72% <28.57%> (-1.5%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 21b6e2a...953dae5. Read the comment docs.

this.componentDidUpdate();
}, 300);
}
this.refs.searchInput.focus();
Copy link
Contributor

Choose a reason for hiding this comment

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

上面不是注释说加 setTimeout 解决 android 兼容性么,这里去掉会不会有问题?测试一下

Copy link
Contributor Author

Choose a reason for hiding this comment

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

通过blurFromOnClear来规避。基本都测过了

Copy link
Contributor

Choose a reason for hiding this comment

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

那注释删掉

focus: false,
});
}
this.blurFromOnClear = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

这行多余了

Copy link
Contributor

Choose a reason for hiding this comment

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

这里的逻辑也有点怪,视觉上上让用户感觉没有 blur,但是又会触发他的回调

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这行多余了

这一行没有多余

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里的逻辑也有点怪,视觉上上让用户感觉没有 blur,但是又会触发他的回调

这里也正常,因为实际上确实是触发onBlur了,对应的,必须是要触发回调。视觉上仅仅是取消了两个不应该有的动画

@@ -74,14 +76,18 @@ export default class SearchBar extends React.Component<SearchBarProps, SearchBar
clearTimeout(this.scrollIntoViewTimeout);
this.scrollIntoViewTimeout = null;
}
if (this.onBlurTimeout) {
clearTimeout(this.onBlurTimeout);
this.onBlurTimeout = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

这个应该也多余,组件都 unmount 了

});
}
this.blurFromOnClear = false;
}, 50);
Copy link
Contributor

Choose a reason for hiding this comment

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

另外下面的 onClear 里面为什么没有cancel onBlurTimeout ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clear Icon被点击的时候会触发onClear,触发的条件是在点击的瞬间Icon可以被点击(可见),要求在点击icon的时候不触发onBlur里的setState({focus: false}); (会导致Icon隐藏)。
所以 这个问题没有为什么。

@paranoidjk
Copy link
Contributor

另外可以随 PR 一起补上 changelog。

等 PR 被合并之后,记得手动同步到 master。

@ghost ghost assigned pingan1927 Aug 28, 2017
@ghost ghost added the In Progress label Aug 28, 2017
@pingan1927 pingan1927 merged commit 42003c4 into 1.x Aug 28, 2017
@paranoidjk paranoidjk deleted the fix-searchbar-onclear2 branch August 28, 2017 13:26
@paranoidjk
Copy link
Contributor

@pingan1927 不要忘了手动 copy 到 master

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.

3 participants