-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes #46 by making sure that pending timeouts are cleared on unmount, for cases like modal layers and portals
- Loading branch information
Showing
18 changed files
with
160 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ var DropdownList = React.createClass({ | |
|
||
mixins: [ | ||
require('./mixins/WidgetMixin'), | ||
require('./mixins/TimeoutMixin'), | ||
require('./mixins/PureRenderMixin'), | ||
require('./mixins/DataHelpersMixin'), | ||
require('./mixins/PopupScrollToMixin'), | ||
|
@@ -72,6 +73,8 @@ var DropdownList = React.createClass({ | |
getInitialState: function(){ | ||
var initialIdx = this._dataIndexOf(this.props.data, this.props.value); | ||
|
||
this._timers = Object.create(null); | ||
|
||
return { | ||
selectedItem: this.props.data[initialIdx], | ||
focusedItem: this.props.data[initialIdx] || this.props.data[0], | ||
|
@@ -90,7 +93,7 @@ var DropdownList = React.createClass({ | |
} | ||
}, | ||
|
||
componentDidMount: function() { | ||
componentDidMount() { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
schutterp
|
||
validateList(this.refs.list) | ||
}, | ||
|
||
|
@@ -170,20 +173,17 @@ var DropdownList = React.createClass({ | |
}, | ||
|
||
_focus: function(focused, e){ | ||
var self = this; | ||
|
||
clearTimeout(self.timer) | ||
self.timer = setTimeout(function(){ | ||
this.setTimeout('focus', () => { | ||
|
||
if(focused) self.getDOMNode().focus() | ||
else self.close() | ||
if(focused) this.getDOMNode().focus() | ||
else this.close() | ||
|
||
if( focused !== self.state.focused){ | ||
self.notify(focused ? 'onFocus' : 'onBlur', e) | ||
self.setState({ focused: focused }) | ||
if( focused !== this.state.focused){ | ||
this.notify(focused ? 'onFocus' : 'onBlur', e) | ||
this.setState({ focused: focused }) | ||
} | ||
|
||
}, 0) | ||
}) | ||
}, | ||
|
||
_onSelect: function(data){ | ||
|
@@ -262,10 +262,9 @@ var DropdownList = React.createClass({ | |
search: function(character, cb){ | ||
var word = ((this._searchTerm || '') + character).toLowerCase(); | ||
|
||
clearTimeout(this._timer) | ||
this._searchTerm = word | ||
|
||
this._timer = setTimeout(() => { | ||
this.setTimeout('search', () => { | ||
var list = this.refs.list | ||
, key = this.props.open ? 'focusedItem' : 'selectedItem' | ||
, item = list.next(this.state[key], word); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
looks like an unintended code change here