switcherPopup: Select correct item after removal of item
If an item was removed, make sure the selected item is still selected or select the last one if the selected item was removed. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/167
This commit is contained in:
parent
ba7cfff90c
commit
c00f1d040b
@ -255,7 +255,15 @@ var SwitcherPopup = GObject.registerClass({
|
|||||||
|
|
||||||
_itemRemovedHandler(n) {
|
_itemRemovedHandler(n) {
|
||||||
if (this._items.length > 0) {
|
if (this._items.length > 0) {
|
||||||
let newIndex = Math.min(n, this._items.length - 1);
|
let newIndex;
|
||||||
|
|
||||||
|
if (n < this._selectedIndex)
|
||||||
|
newIndex = this._selectedIndex - 1;
|
||||||
|
else if (n === this._selectedIndex)
|
||||||
|
newIndex = Math.min(n, this._items.length - 1);
|
||||||
|
else if (n > this._selectedIndex)
|
||||||
|
return; // No need to select something new in this case
|
||||||
|
|
||||||
this._select(newIndex);
|
this._select(newIndex);
|
||||||
} else {
|
} else {
|
||||||
this.fadeAndDestroy();
|
this.fadeAndDestroy();
|
||||||
|
Loading…
Reference in New Issue
Block a user