Bug 860055 - SideMenuWidget shouldn't scroll back to the selected item when new requests are coming in, r=dcamp

This commit is contained in:
Victor Porof 2013-04-11 21:11:46 +03:00
parent 3ce07a9bc8
commit 8790fa745f
2 changed files with 10 additions and 1 deletions

View File

@ -260,6 +260,7 @@ create({ constructor: RequestsMenuView, proto: MenuContainer.prototype }, {
dumpn("Initializing the RequestsMenuView");
this.node = new SideMenuWidget($("#requests-menu-contents"), false);
this.node.maintainSelectionVisible = false;
this.node.addEventListener("mousedown", this._onMouseDown, false);
this.node.addEventListener("select", this._onSelect, false);

View File

@ -63,6 +63,12 @@ SideMenuWidget.prototype = {
get document() this._parent.ownerDocument,
get window() this.document.defaultView,
/**
* Specifies if this container should try to keep the selected item visible.
* (For example, when new items are added the selection is brought into view).
*/
maintainSelectionVisible: true,
/**
* Specifies if groups in this container should be sorted alphabetically.
*/
@ -84,7 +90,9 @@ SideMenuWidget.prototype = {
* The element associated with the displayed item.
*/
insertItemAt: function SMW_insertItemAt(aIndex, aContents, aTooltip = "", aGroup = "") {
if (this.maintainSelectionVisible) {
this.ensureSelectionIsVisible(true, true); // Don't worry, it's delayed.
}
let group = this._getGroupForName(aGroup);
return group.insertItemAt(aIndex, aContents, aTooltip, this._showArrows);