提交 40723965 编写于 作者: J Johannes Rieken

bc - properly cleanup selection and focus when leaving breadcrumbs

上级 12567143
......@@ -192,6 +192,7 @@ export class BreadcrumbsWidget {
}
private _focus(nth: number, payload: any): void {
const oldIdx = this._focusedItemIdx;
this._focusedItemIdx = -1;
for (let i = 0; i < this._nodes.length; i++) {
const node = this._nodes[i];
......@@ -203,8 +204,10 @@ export class BreadcrumbsWidget {
node.focus();
}
}
this._reveal(this._focusedItemIdx);
this._onDidFocusItem.fire({ type: 'focus', item: this._items[this._focusedItemIdx], node: this._nodes[this._focusedItemIdx], payload });
if (this._focusedItemIdx !== oldIdx) {
this._reveal(this._focusedItemIdx);
this._onDidFocusItem.fire({ type: 'focus', item: this._items[this._focusedItemIdx], node: this._nodes[this._focusedItemIdx], payload });
}
}
reveal(item: BreadcrumbsItem): void {
......@@ -232,6 +235,7 @@ export class BreadcrumbsWidget {
}
private _select(nth: number, payload: any): void {
const oldIdx = this._selectedItemIdx;
this._selectedItemIdx = -1;
for (let i = 0; i < this._nodes.length; i++) {
const node = this._nodes[i];
......@@ -242,7 +246,9 @@ export class BreadcrumbsWidget {
dom.addClass(node, 'selected');
}
}
this._onDidSelectItem.fire({ type: 'select', item: this._items[this._selectedItemIdx], node: this._nodes[this._selectedItemIdx], payload });
if (this._selectedItemIdx !== oldIdx) {
this._onDidSelectItem.fire({ type: 'select', item: this._items[this._selectedItemIdx], node: this._nodes[this._selectedItemIdx], payload });
}
}
getItems(): ReadonlyArray<BreadcrumbsItem> {
......
......@@ -233,7 +233,7 @@ export class BreadcrumbsControl {
this._breadcrumbsDisposables.push({
dispose: () => {
if (this._breadcrumbsPickerShowing) {
this._contextViewService.hideContextView();
this._contextViewService.hideContextView(this);
}
}
});
......@@ -277,9 +277,7 @@ export class BreadcrumbsControl {
render: (parent: HTMLElement) => {
picker = createBreadcrumbsPicker(this._instantiationService, parent, element);
let listener = picker.onDidPickElement(data => {
this._contextViewService.hideContextView();
this._widget.setFocused(undefined);
this._widget.setSelection(undefined);
this._contextViewService.hideContextView(this);
this._revealInEditor(event, data);
});
this._breadcrumbsPickerShowing = true;
......@@ -309,9 +307,13 @@ export class BreadcrumbsControl {
picker.setInput(element);
return { x, y };
},
onHide: () => {
onHide: (data) => {
this._breadcrumbsPickerShowing = false;
this._updateCkBreadcrumbsActive();
if (data === this) {
this._widget.setFocused(undefined);
this._widget.setSelection(undefined);
}
}
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册