Skip to content

Commit

Permalink
progress - stop animation when a modal dialog is visible (#138396)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Dec 14, 2021
1 parent fdd6a7e commit f4bcb5e
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 30 deletions.
3 changes: 3 additions & 0 deletions src/vs/editor/standalone/browser/simpleServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ export class SimpleDialogService implements IDialogService {

public _serviceBrand: undefined;

readonly onWillShowDialog = Event.None;
readonly onDidShowDialog = Event.None;

public confirm(confirmation: IConfirmation): Promise<IConfirmationResult> {
return this.doConfirm(confirmation).then(confirmed => {
return {
Expand Down
14 changes: 14 additions & 0 deletions src/vs/platform/dialogs/common/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Event } from 'vs/base/common/event';
import { Codicon } from 'vs/base/common/codicons';
import { IMarkdownString } from 'vs/base/common/htmlContent';
import { basename } from 'vs/base/common/resources';
Expand Down Expand Up @@ -107,6 +108,7 @@ export interface IPickAndOpenOptions {
}

export interface ISaveDialogOptions {

/**
* A human-readable string for the dialog title
*/
Expand Down Expand Up @@ -136,6 +138,7 @@ export interface ISaveDialogOptions {
}

export interface IOpenDialogOptions {

/**
* A human-readable string for the dialog title
*/
Expand Down Expand Up @@ -211,6 +214,7 @@ export interface IInput {
* A handler to bring up modal dialogs.
*/
export interface IDialogHandler {

/**
* Ask the user for confirmation with a modal dialog.
*/
Expand Down Expand Up @@ -251,6 +255,16 @@ export interface IDialogService {

readonly _serviceBrand: undefined;

/**
* An event that fires when a dialog is about to show.
*/
onWillShowDialog: Event<void>;

/**
* An event that fires when a dialog did show (closed).
*/
onDidShowDialog: Event<void>;

/**
* Ask the user for confirmation with a modal dialog.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/vs/platform/dialogs/test/common/testDialogService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Event } from 'vs/base/common/event';
import Severity from 'vs/base/common/severity';
import { IConfirmation, IConfirmationResult, IDialogOptions, IDialogService, IInputResult, IShowResult } from 'vs/platform/dialogs/common/dialogs';

export class TestDialogService implements IDialogService {

declare readonly _serviceBrand: undefined;

readonly onWillShowDialog = Event.None;
readonly onDidShowDialog = Event.None;

private confirmResult: IConfirmationResult | undefined = undefined;
setConfirmResult(result: IConfirmationResult) {
this.confirmResult = result;
Expand Down
14 changes: 9 additions & 5 deletions src/vs/workbench/browser/media/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ body.web {
cursor: default;
}

.monaco-workbench .codicon[class*='codicon-'] {
font-size: 16px; /* sets font-size for codicons in workbench (https://github.com/microsoft/vscode/issues/98495) */
}

.monaco-workbench.modal-dialog-visible .monaco-progress-container.infinite .progress-bit {
display: none; /* stop progress animations when dialogs are visible (https://github.com/microsoft/vscode/issues/138396) */
}

/* Custom Dropdown (select) Arrows */

.monaco-workbench select {
Expand Down Expand Up @@ -208,7 +216,7 @@ body.web {
pointer-events: none;
}

/* START Keyboard Focus Indication Styles */
/* Keyboard Focus Indication Styles */

.monaco-workbench [tabindex="0"]:focus,
.monaco-workbench [tabindex="-1"]:focus,
Expand Down Expand Up @@ -271,7 +279,3 @@ body.web {
.monaco-workbench .monaco-list:focus {
outline: 0 !important; /* tree indicates focus not via outline but through the focused item */
}

.monaco-workbench .codicon[class*='codicon-'] {
font-size: 16px; /* sets font-size for codicons in workbench https://github.com/microsoft/vscode/issues/98495 */
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class DialogHandlerContribution extends Disposable implements IWorkbenchC

this.model = (this.dialogService as DialogService).model;

this._register(this.model.onDidShowDialog(() => {
this._register(this.model.onWillShowDialog(() => {
if (!this.currentDialog) {
this.processDialogs();
}
Expand Down
10 changes: 8 additions & 2 deletions src/vs/workbench/browser/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { coalesce } from 'vs/base/common/arrays';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { Layout } from 'vs/workbench/browser/layout';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';

export interface IWorkbenchOptions {

Expand Down Expand Up @@ -142,6 +143,7 @@ export class Workbench extends Layout {
const storageService = accessor.get(IStorageService);
const configurationService = accessor.get(IConfigurationService);
const hostService = accessor.get(IHostService);
const dialogService = accessor.get(IDialogService);

// Layout
this.initLayout(accessor);
Expand All @@ -154,7 +156,7 @@ export class Workbench extends Layout {
this._register(instantiationService.createInstance(WorkbenchContextKeysHandler));

// Register Listeners
this.registerListeners(lifecycleService, storageService, configurationService, hostService);
this.registerListeners(lifecycleService, storageService, configurationService, hostService, dialogService);

// Render Workbench
this.renderWorkbench(instantiationService, accessor.get(INotificationService) as NotificationService, storageService, configurationService);
Expand Down Expand Up @@ -219,7 +221,7 @@ export class Workbench extends Layout {
return instantiationService;
}

private registerListeners(lifecycleService: ILifecycleService, storageService: IStorageService, configurationService: IConfigurationService, hostService: IHostService): void {
private registerListeners(lifecycleService: ILifecycleService, storageService: IStorageService, configurationService: IConfigurationService, hostService: IHostService, dialogService: IDialogService): void {

// Configuration changes
this._register(configurationService.onDidChangeConfiguration(() => this.setFontAliasing(configurationService)));
Expand Down Expand Up @@ -252,6 +254,10 @@ export class Workbench extends Layout {
storageService.flush();
}
}));

// Dialogs showing/hiding
this._register(dialogService.onWillShowDialog(() => this.container.classList.add('modal-dialog-visible')));
this._register(dialogService.onDidShowDialog(() => this.container.classList.remove('modal-dialog-visible')));
}

private fontAliasing: 'default' | 'antialiased' | 'none' | 'auto' | undefined;
Expand Down
7 changes: 6 additions & 1 deletion src/vs/workbench/common/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface IDialogHandle {

export interface IDialogsModel {

readonly onWillShowDialog: Event<void>;
readonly onDidShowDialog: Event<void>;

readonly dialogs: IDialogViewItem[];
Expand All @@ -31,6 +32,9 @@ export class DialogsModel extends Disposable implements IDialogsModel {

readonly dialogs: IDialogViewItem[] = [];

private readonly _onWillShowDialog = this._register(new Emitter<void>());
readonly onWillShowDialog = this._onWillShowDialog.event;

private readonly _onDidShowDialog = this._register(new Emitter<void>());
readonly onDidShowDialog = this._onDidShowDialog.event;

Expand All @@ -42,11 +46,12 @@ export class DialogsModel extends Disposable implements IDialogsModel {
close: result => {
this.dialogs.splice(0, 1);
promise.complete(result);
this._onDidShowDialog.fire();
}
};

this.dialogs.push(item);
this._onDidShowDialog.fire();
this._onWillShowDialog.fire();

return {
item,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class DialogHandlerContribution extends Disposable implements IWorkbenchC

this.model = (this.dialogService as DialogService).model;

this._register(this.model.onDidShowDialog(() => {
this._register(this.model.onWillShowDialog(() => {
if (!this.currentDialog) {
this.processDialogs();
}
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/services/dialogs/common/dialogService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export class DialogService extends Disposable implements IDialogService {

readonly model = this._register(new DialogsModel());

readonly onWillShowDialog = this.model.onWillShowDialog;

readonly onDidShowDialog = this.model.onDidShowDialog;

async confirm(confirmation: IConfirmation): Promise<IConfirmationResult> {
const handle = this.model.show({ confirmArgs: { confirmation } });

Expand Down
22 changes: 2 additions & 20 deletions src/vs/workbench/test/browser/api/extHostMessagerService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import { mock } from 'vs/base/test/common/mock';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
import { Event } from 'vs/base/common/event';

const emptyDialogService = new class implements IDialogService {
declare readonly _serviceBrand: undefined;
show(): never {
throw new Error('not implemented');
}

confirm(): never {
throw new Error('not implemented');
}

about(): never {
throw new Error('not implemented');
}

input(): never {
throw new Error('not implemented');
}
};
import { TestDialogService } from 'vs/platform/dialogs/test/common/testDialogService';

const emptyCommandService: ICommandService = {
_serviceBrand: undefined,
Expand Down Expand Up @@ -107,7 +89,7 @@ suite('ExtHostMessageService', function () {
let service = new MainThreadMessageService(null!, new EmptyNotificationService(notification => {
assert.strictEqual(notification.actions!.primary!.length, 1);
queueMicrotask(() => notification.actions!.primary![0].run());
}), emptyCommandService, emptyDialogService);
}), emptyCommandService, new TestDialogService());

const handle = await service.$showMessage(1, 'h', {}, [{ handle: 42, title: 'a thing', isCloseAffordance: true }]);
assert.strictEqual(handle, 42);
Expand Down

0 comments on commit f4bcb5e

Please sign in to comment.