Bug 1146946 - Handle empty lists in sidebar.js when using the up/down key. r=florian
authorBlake Winton <bwinton@latte.ca>
Tue, 24 Mar 2015 15:12:17 -0400
changeset 265822 a4cab686efdd79512e23d5977a01b2fbc5dc9a50
parent 265821 538dfc749e7344ac907f9e83a6df8e272b63ea54
child 265823 6d9a05956ad88a42d9bcd823e63e0d1b89400c23
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1146946
milestone39.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 1146946 - Handle empty lists in sidebar.js when using the up/down key. r=florian
browser/components/readinglist/sidebar.js
--- a/browser/components/readinglist/sidebar.js
+++ b/browser/components/readinglist/sidebar.js
@@ -402,26 +402,33 @@ let RLSidebar = {
    * Handle a keydown event on the list box.
    * @param {Event} event - Triggering event.
    */
   onListKeyDown(event) {
     if (event.keyCode == KeyEvent.DOM_VK_DOWN) {
       // TODO: Refactor this so we pass a direction to a generic method.
       // See autocomplete.xml's getNextIndex
       event.preventDefault();
+
+      if (!this.numItems) {
+        return;
+      }
       let index = this.selectedIndex + 1;
       if (index >= this.numItems) {
         index = 0;
       }
 
       this.selectedIndex = index;
       this.selectedItem.focus();
     } else if (event.keyCode == KeyEvent.DOM_VK_UP) {
       event.preventDefault();
 
+      if (!this.numItems) {
+        return;
+      }
       let index = this.selectedIndex - 1;
       if (index < 0) {
         index = this.numItems - 1;
       }
 
       this.selectedIndex = index;
       this.selectedItem.focus();
     } else if (event.keyCode == KeyEvent.DOM_VK_RETURN) {