Bug 1538164 - [release 130] 8118/fix quick open modal nan bug (#8136).

Differential Revision: https://phabricator.services.mozilla.com/D24774

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tyler Wendlandt 2019-03-26 15:24:35 +00:00
parent 83fa0aa6cc
commit 062fce54c0
2 changed files with 2 additions and 2 deletions

View File

@ -235,7 +235,7 @@ export class QuickOpenModal extends Component<Props, State> {
const { selectedIndex, results } = this.state;
const resultCount = this.getResultCount();
const index = selectedIndex + direction;
const nextIndex = (index + resultCount) % resultCount;
const nextIndex = (index + resultCount) % resultCount || 0;
this.setState({ selectedIndex: nextIndex });

View File

@ -636,7 +636,7 @@ describe("QuickOpenModal", () => {
}));
wrapper.find("SearchInput").simulate("keydown", event);
expect(event.preventDefault).toHaveBeenCalled();
expect(wrapper.state().selectedIndex).toEqual(NaN);
expect(wrapper.state().selectedIndex).toEqual(0);
expect(props.selectSpecificLocation).not.toHaveBeenCalledWith();
expect(props.highlightLineRange).not.toHaveBeenCalled();
});