Skip to content

Commit

Permalink
[core] Don't scroll when re-setting focus on widgets.
Browse files Browse the repository at this point in the history
Fixes #4901

Signed-off-by: Sven Efftinge <sven.efftinge@typefox.io>
  • Loading branch information
svenefftinge committed Nov 25, 2019
1 parent 145f913 commit b8c5e18
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/browser/menu/browser-menu-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class DynamicMenuWidget extends MenuWidget {
// we want to restore the focus after the menu closes.
const previouslyActive = window.document.activeElement as HTMLElement;
const cb = () => {
previouslyActive.focus();
previouslyActive.focus({ preventScroll: true });
this.aboutToClose.disconnect(cb);
};
this.aboutToClose.connect(cb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class CommandQuickOpenItem extends QuickOpenGroupItem {
// allow the quick open widget to close itself
setTimeout(() => {
// reset focus on the previously active element.
this.activeElement.focus();
this.activeElement.focus({ preventScroll: true });
this.commands.executeCommand(this.command.id);
}, 50);
return true;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/tree/tree-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {

protected onActivateRequest(msg: Message): void {
super.onActivateRequest(msg);
this.node.focus();
this.node.focus({ preventScroll: true });
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/view-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ export class ViewContainer extends BaseWidget implements StatefulWidget, Applica
if (this.currentPart) {
this.currentPart.activate();
} else {
this.panel.node.focus();
this.panel.node.focus({ preventScroll: true });
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/git/src/browser/diff/git-diff-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ export class GitDiffListContainer extends React.Component<GitDiffListContainer.P

focus(): void {
if (this.listContainer) {
this.listContainer.focus();
this.listContainer.focus({ preventScroll: true });
}
}
}
2 changes: 1 addition & 1 deletion packages/monaco/src/browser/monaco-quick-open-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export class MonacoQuickOpenService extends QuickOpenService {
},
onCancel: () => {
if (this.previousActiveElement instanceof HTMLElement) {
this.previousActiveElement.focus();
this.previousActiveElement.focus({ preventScroll: true });
}
this.previousActiveElement = undefined;
this.contextKeyService.activeContext = undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/main/browser/quick-open-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class QuickOpenMainImpl implements QuickOpenMain, QuickOpenModel, Disposa
this.items = undefined;
this.acceptor = undefined;
if (this.activeElement) {
this.activeElement.focus();
this.activeElement.focus({ preventScroll: true });
}
this.activeElement = undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/main/browser/workspace-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class WorkspaceMainImpl implements WorkspaceMain, Disposable {
placeholder: options.placeHolder,
onClose: () => {
if (activeElement) {
activeElement.focus();
activeElement.focus({ preventScroll: true });
}

resolve(returnValue);
Expand Down

0 comments on commit b8c5e18

Please sign in to comment.