mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-27 10:33:56 +08:00
fix(menu): Fix flashing selection as you type
This commit is contained in:
parent
afe1168acc
commit
818bca892c
1 changed files with 3 additions and 7 deletions
|
@ -103,19 +103,15 @@ Menu = React.createClass
|
|||
# finding an item in the new list with a key matching the old
|
||||
# selected item's key
|
||||
selection = @props.items[@state.selectedIndex]
|
||||
newSelectionIndex = 0
|
||||
|
||||
if selection?
|
||||
selectionKey = @props.itemKey(selection)
|
||||
newSelection = _.find newProps.items, (item) => @props.itemKey(item) is selectionKey
|
||||
|
||||
newSelectionIndex = -1
|
||||
newSelectionIndex = newProps.items.indexOf(newSelection) if newSelection?
|
||||
|
||||
@setState
|
||||
selectedIndex: newSelectionIndex
|
||||
else
|
||||
@setState
|
||||
selectedIndex: 0
|
||||
@setState
|
||||
selectedIndex: newSelectionIndex
|
||||
|
||||
componentWillUnmount: ->
|
||||
@subscriptions?.dispose()
|
||||
|
|
Loading…
Reference in a new issue