From 818bca892c05ee209a7cf104925037d79245a50d Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Thu, 12 Mar 2015 11:43:56 -0700 Subject: [PATCH] fix(menu): Fix flashing selection as you type --- src/components/menu.cjsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/menu.cjsx b/src/components/menu.cjsx index 16145b93d..36b90f31b 100644 --- a/src/components/menu.cjsx +++ b/src/components/menu.cjsx @@ -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()