Bug 1538164 - [release 130] 8118/fix quick open modal nan bug (#8136).
authorTyler Wendlandt <twendlan@ualberta.ca>
Tue, 26 Mar 2019 15:24:35 +0000
changeset 466176 8cce06978488196bb99556cfbfda0f2010860df6
parent 466175 bec75003e88c9f2a782001cba6a603433724d94b
child 466177 4ee50a9f2b2bc139b239686f18e8a98f73515871
push id35762
push usercsabou@mozilla.com
push dateWed, 27 Mar 2019 04:44:00 +0000
treeherdermozilla-central@bc572aee49b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1538164
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1538164 - [release 130] 8118/fix quick open modal nan bug (#8136). Differential Revision: https://phabricator.services.mozilla.com/D24774
devtools/client/debugger/new/src/components/QuickOpenModal.js
devtools/client/debugger/new/src/components/test/QuickOpenModal.spec.js
--- a/devtools/client/debugger/new/src/components/QuickOpenModal.js
+++ b/devtools/client/debugger/new/src/components/QuickOpenModal.js
@@ -230,17 +230,17 @@ export class QuickOpenModal extends Comp
     }
   };
 
   traverseResults = (e: SyntheticKeyboardEvent<HTMLElement>) => {
     const direction = e.key === "ArrowUp" ? -1 : 1;
     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 });
 
     if (results != null) {
       this.onSelectResultItem(results[nextIndex]);
     }
   };
 
--- a/devtools/client/debugger/new/src/components/test/QuickOpenModal.spec.js
+++ b/devtools/client/debugger/new/src/components/test/QuickOpenModal.spec.js
@@ -631,17 +631,17 @@ describe("QuickOpenModal", () => {
         key: "ArrowDown"
       };
       wrapper.setState(() => ({
         results: null,
         selectedIndex: 1
       }));
       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();
     });
 
     it("on ArrowUp, traverse results up to function with no location", () => {
       const sourceId = "sourceId";
       const { wrapper, props } = generateModal(
         {