Skip to content

Commit

Permalink
fix focus
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed Apr 19, 2016
1 parent cd00fdd commit a4f1636
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-trigger",
"version": "1.4.1",
"version": "1.4.2",
"description": "base abstract trigger component for react",
"keywords": [
"react",
Expand Down
17 changes: 11 additions & 6 deletions src/Trigger.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ const Trigger = React.createClass({
},

onFocus() {
this.focusTime = Date.now();
this.delaySetPopupVisible(true, this.props.focusDelay);
// incase focusin and focusout
this.clearDelayTimer();
if (this.isFocusToShow()) {
this.focusTime = Date.now();
this.delaySetPopupVisible(true, this.props.focusDelay);
}
},

onMouseDown() {
Expand All @@ -170,7 +174,10 @@ const Trigger = React.createClass({
},

onBlur() {
this.delaySetPopupVisible(false, this.props.blurDelay);
this.clearDelayTimer();
if (this.isBlurToHide()) {
this.delaySetPopupVisible(false, this.props.blurDelay);
}
},

onClick(event) {
Expand Down Expand Up @@ -364,11 +371,9 @@ const Trigger = React.createClass({
newChildProps.onMouseLeave = createChainedFunction(this.onMouseLeave,
childProps.onMouseLeave);
}
if (this.isFocusToShow()) {
if (this.isFocusToShow() || this.isBlurToHide()) {
newChildProps.onFocus = createChainedFunction(this.onFocus,
childProps.onFocus);
}
if (this.isBlurToHide()) {
newChildProps.onBlur = createChainedFunction(this.onBlur,
childProps.onBlur);
}
Expand Down

0 comments on commit a4f1636

Please sign in to comment.