提交 7fdb1e79 编写于 作者: S Sandeep Somavarapu

Fix #50246

上级 37886aa1
...@@ -121,7 +121,7 @@ export class CompositeBar extends Widget implements ICompositeBar { ...@@ -121,7 +121,7 @@ export class CompositeBar extends Widget implements ICompositeBar {
public addComposite({ id, name, order }: { id: string; name: string, order: number }, open: boolean): void { public addComposite({ id, name, order }: { id: string; name: string, order: number }, open: boolean): void {
const state = this.storedState.filter(s => s.id === id)[0]; const state = this.storedState.filter(s => s.id === id)[0];
const pinned = state ? state.pinned : true; const pinned = state ? state.pinned : true;
let index = this.model.items.length; let index = order >= 0 ? order : this.model.items.length;
if (state) { if (state) {
// Find the index by looking its previous item // Find the index by looking its previous item
...@@ -137,9 +137,10 @@ export class CompositeBar extends Widget implements ICompositeBar { ...@@ -137,9 +137,10 @@ export class CompositeBar extends Widget implements ICompositeBar {
} }
// Add to the model // Add to the model
if (this.addToModel(id, name, order, pinned, index)) { if (this.model.add(id, name, order, index)) {
if (open) { this.computeSizes([this.model.findItem(id)]);
this.pin(id, true); if (pinned || open) {
this.pin(id, open);
} else { } else {
this.updateCompositeSwitcher(); this.updateCompositeSwitcher();
} }
...@@ -259,14 +260,6 @@ export class CompositeBar extends Widget implements ICompositeBar { ...@@ -259,14 +260,6 @@ export class CompositeBar extends Widget implements ICompositeBar {
return item && item.activityAction; return item && item.activityAction;
} }
private addToModel(id: string, name: string, order: number, pinned: boolean, index: number): boolean {
if (this.model.add(id, name, order, pinned, index)) {
this.computeSizes([this.model.findItem(id)]);
return true;
}
return false;
}
private computeSizes(items: ICompositeBarItem[]): void { private computeSizes(items: ICompositeBarItem[]): void {
const size = this.options.compositeSize; const size = this.options.compositeSize;
if (size) { if (size) {
...@@ -482,7 +475,7 @@ class CompositeBarModel { ...@@ -482,7 +475,7 @@ class CompositeBarModel {
}; };
} }
add(id: string, name: string, order: number, pinned: boolean, index: number): boolean { add(id: string, name: string, order: number, index: number): boolean {
const item = this.findItem(id); const item = this.findItem(id);
if (item) { if (item) {
item.order = order; item.order = order;
...@@ -495,7 +488,7 @@ class CompositeBarModel { ...@@ -495,7 +488,7 @@ class CompositeBarModel {
index++; index++;
} }
} }
this.items.splice(index, 0, this.createCompositeBarItem(id, name, order, pinned)); this.items.splice(index, 0, this.createCompositeBarItem(id, name, order, false));
return true; return true;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册