fix normal dialog vertical scrolling issue (#23177)

This commit is contained in:
Alan Ren
2023-05-19 16:51:55 -07:00
committed by GitHub
parent e322641538
commit 5356cd7748
10 changed files with 64 additions and 33 deletions

View File

@@ -18,12 +18,21 @@
border-width: 1px; border-width: 1px;
} }
.modal:not(.flyout-dialog):not(.callout-dialog) .modal-dialog { .modal.normal-dialog .modal-dialog {
margin: auto; margin: auto;
width: 640px; width: 640px;
max-height: 480px;
} }
.modal.normal-dialog .modal-dialog .modal-content {
display: flex;
flex-direction: column;
height: 100%;
}
.modal.normal-dialog .modal-dialog .modal-content .modal-body {
flex: 1 1 auto;
overflow-y: auto;
}
.modal .modal-header { .modal .modal-header {
padding: 15px; padding: 15px;
} }

View File

@@ -85,6 +85,10 @@ export interface IModalOptions {
renderHeader?: boolean; renderHeader?: boolean;
renderFooter?: boolean; renderFooter?: boolean;
dialogProperties?: IDialogProperties; dialogProperties?: IDialogProperties;
/**
* The height of the dialog, only applicable when the dialog style is normal.
*/
height?: number;
} }
const defaultOptions: IModalOptions = { const defaultOptions: IModalOptions = {
@@ -98,7 +102,8 @@ const defaultOptions: IModalOptions = {
hasSpinner: true, hasSpinner: true,
renderHeader: true, renderHeader: true,
renderFooter: true, renderFooter: true,
dialogProperties: undefined dialogProperties: undefined,
height: 480
}; };
export type HideReason = 'close' | 'cancel' | 'ok'; export type HideReason = 'close' | 'cancel' | 'ok';
@@ -210,9 +215,16 @@ export abstract class Modal extends Disposable implements IThemable {
let top: number; let top: number;
let builderClass = '.modal.fade'; let builderClass = '.modal.fade';
builderClass += this._modalOptions.dialogStyle === 'flyout' ? '.flyout-dialog' switch (this._modalOptions.dialogStyle) {
: this._modalOptions.dialogStyle === 'callout' ? '.callout-dialog' case 'flyout':
: ''; builderClass += '.flyout-dialog';
break;
case 'callout':
builderClass += '.callout-dialog';
break;
default:
builderClass += '.normal-dialog';
}
this._bodyContainer = DOM.$(`${builderClass}`, { role: 'dialog', 'aria-label': this._title }); this._bodyContainer = DOM.$(`${builderClass}`, { role: 'dialog', 'aria-label': this._title });
@@ -225,6 +237,12 @@ export abstract class Modal extends Disposable implements IThemable {
this._modalDialog = DOM.append(this._bodyContainer, DOM.$('.modal-dialog')); this._modalDialog = DOM.append(this._bodyContainer, DOM.$('.modal-dialog'));
const formElement = DOM.append(this._modalDialog, DOM.$('form')); const formElement = DOM.append(this._modalDialog, DOM.$('form'));
if (this._modalOptions.dialogStyle === 'normal') {
// set the height based on the available space and the expected height.
// so that the dialog can scroll vertically when needed.
this._modalDialog.style.height = `min(100%, ${this._modalOptions.height}px)`;
}
if (this._modalOptions.dialogStyle === 'callout') { if (this._modalOptions.dialogStyle === 'callout') {
let arrowClass = `.callout-arrow.from-${this._modalOptions.dialogPosition}`; let arrowClass = `.callout-arrow.from-${this._modalOptions.dialogPosition}`;
this._modalContent = DOM.append(formElement, DOM.$(`.modal-content${arrowClass}`)); this._modalContent = DOM.append(formElement, DOM.$(`.modal-content${arrowClass}`));

View File

@@ -3,18 +3,11 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
.change-password-dialog { .change-password-dialog {
padding: 30px; padding: 10px;
height: 100%;
overflow: hidden;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.change-password-dialog .properties-content {
flex: 1 1 auto;
overflow-y: auto;
}
.change-password-dialog .component-label-bold { .change-password-dialog .component-label-bold {
font-weight: 600; font-weight: 600;
padding-bottom: 30px; padding-bottom: 30px;

View File

@@ -57,7 +57,7 @@ export class PasswordChangeDialog extends Modal {
@IContextViewService private readonly contextViewService: IContextViewService, @IContextViewService private readonly contextViewService: IContextViewService,
@ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService, @ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService,
) { ) {
super('', '', telemetryService, layoutService, clipboardService, themeService, logService, textResourcePropertiesService, contextKeyService, { hasSpinner: true, spinnerTitle: passwordChangeLoadText, dialogStyle: 'normal', width: dialogWidth, dialogPosition: 'left' }); super('', '', telemetryService, layoutService, clipboardService, themeService, logService, textResourcePropertiesService, contextKeyService, { hasSpinner: true, spinnerTitle: passwordChangeLoadText, dialogStyle: 'normal', width: dialogWidth, dialogPosition: 'left', height: 350 });
} }
public open(profile: IConnectionProfile): Promise<string> { public open(profile: IConnectionProfile): Promise<string> {

View File

@@ -62,7 +62,7 @@ export class ErrorMessageDialog extends Modal {
@IOpenerService private readonly _openerService: IOpenerService, @IOpenerService private readonly _openerService: IOpenerService,
protected _telemetryView: TelemetryKeys.TelemetryView | string = TelemetryKeys.TelemetryView.ErrorMessageDialog, protected _telemetryView: TelemetryKeys.TelemetryView | string = TelemetryKeys.TelemetryView.ErrorMessageDialog,
) { ) {
super('', TelemetryKeys.ModalDialogName.ErrorMessage, telemetryService, layoutService, clipboardService, themeService, logService, textResourcePropertiesService, contextKeyService, { dialogStyle: 'normal', hasTitleIcon: true }); super('', TelemetryKeys.ModalDialogName.ErrorMessage, telemetryService, layoutService, clipboardService, themeService, logService, textResourcePropertiesService, contextKeyService, { dialogStyle: 'normal', hasTitleIcon: true, height: 340 });
this._okLabel = localize('errorMessageDialog.ok', "OK"); this._okLabel = localize('errorMessageDialog.ok', "OK");
this._closeLabel = localize('errorMessageDialog.close', "Close"); this._closeLabel = localize('errorMessageDialog.close', "Close");
this._readMoreLabel = localize('errorMessageDialog.readMore', "Read More"); this._readMoreLabel = localize('errorMessageDialog.readMore', "Read More");

View File

@@ -4,9 +4,8 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
.error-dialog { .error-dialog {
padding: 15px; padding: 10px;
overflow: auto; height: calc(100% - 20px);
height: 210px;
} }
.error-dialog .codicon.error, .error-dialog .codicon.warning , .error-dialog .codicon.info { .error-dialog .codicon.error, .error-dialog .codicon.warning , .error-dialog .codicon.info {

View File

@@ -4,10 +4,11 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
.filter-dialog-body { .filter-dialog-body {
height: 400px;
padding: 10px; padding: 10px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: calc(100% - 20px);
overflow: hidden;
} }
.filter-table-container .filter-table { .filter-table-container .filter-table {

View File

@@ -4,8 +4,11 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
.profiler-filter-dialog { .profiler-filter-dialog {
height: 300px;
padding: 10px; padding: 10px;
display: flex;
flex-direction: column;
height: calc(100% - 20px);
overflow: flex;
} }
.profiler-filter-clause-table { .profiler-filter-clause-table {
@@ -14,8 +17,8 @@
} }
.clause-table-container { .clause-table-container {
max-height: 270px;
overflow-y: scroll; overflow-y: scroll;
flex: 1 1 auto;
} }
.profiler-filter-remove-condition { .profiler-filter-remove-condition {
@@ -24,10 +27,14 @@
cursor: pointer; cursor: pointer;
} }
.profiler-filter-dialog .actions-container {
display: flex;
flex-direction: row;
}
.profiler-filter-clause-table-action { .profiler-filter-clause-table-action {
cursor: pointer; cursor: pointer;
margin-right: 10px; margin-right: 10px;
padding: 2px; padding: 2px;
text-decoration: underline; text-decoration: underline;
display: inline-block;
} }

View File

@@ -119,24 +119,27 @@ export class ProfilerFilterDialog extends Modal {
protected renderBody(container: HTMLElement) { protected renderBody(container: HTMLElement) {
const body = DOM.append(container, DOM.$('.profiler-filter-dialog')); const body = DOM.append(container, DOM.$('.profiler-filter-dialog'));
const clauseTableContainer = DOM.append(body, DOM.$('.clause-table-container')); const clauseTableContainer = DOM.append(body, DOM.$('.clause-table-container'));
const actionsContainer = DOM.append(body, DOM.$('.actions-container'));
this._clauseBuilder = DOM.append(clauseTableContainer, DOM.$('table.profiler-filter-clause-table')); this._clauseBuilder = DOM.append(clauseTableContainer, DOM.$('table.profiler-filter-clause-table'));
const headerRow = DOM.append(this._clauseBuilder, DOM.$('tr')); const headerRow = DOM.append(this._clauseBuilder, DOM.$('tr'));
DOM.append(headerRow, DOM.$('td')).innerText = FieldText; DOM.append(headerRow, DOM.$('th')).innerText = FieldText;
DOM.append(headerRow, DOM.$('td')).innerText = OperatorText; DOM.append(headerRow, DOM.$('th')).innerText = OperatorText;
DOM.append(headerRow, DOM.$('td')).innerText = ValueText; DOM.append(headerRow, DOM.$('th')).innerText = ValueText;
DOM.append(headerRow, DOM.$('td')).innerText = ''; DOM.append(headerRow, DOM.$('th')).innerText = '';
this._input!.filter.clauses.forEach(clause => { this._input!.filter.clauses.forEach(clause => {
this.addClauseRow(true, clause.field, this.convertToOperatorString(clause.operator), clause.value); this.addClauseRow(true, clause.field, this.convertToOperatorString(clause.operator), clause.value);
}); });
this.createClauseTableActionLink(AddClauseText, body, () => {
this.createClauseTableActionLink(AddClauseText, actionsContainer, () => {
this.addClauseRow(false); this.addClauseRow(false);
// Set keyboard focus to the newly added clause. // Set keyboard focus to the newly added clause.
this._clauseRows[this._clauseRows.length - 1]?.field?.focus(); this._clauseRows[this._clauseRows.length - 1]?.field?.focus();
aria.status(NewClauseAddedText); aria.status(NewClauseAddedText);
}); });
this.createClauseTableActionLink(ClearText, body, () => { this.handleClearButtonClick(); }); this.createClauseTableActionLink(ClearText, actionsContainer, () => { this.handleClearButtonClick(); });
} }
protected layout(height?: number): void { protected layout(height?: number): void {
@@ -169,7 +172,8 @@ export class ProfilerFilterDialog extends Modal {
private createClauseTableActionLink(text: string, parent: HTMLElement, handler: () => void): void { private createClauseTableActionLink(text: string, parent: HTMLElement, handler: () => void): void {
const actionLink = DOM.append(parent, DOM.$('.profiler-filter-clause-table-action', { const actionLink = DOM.append(parent, DOM.$('.profiler-filter-clause-table-action', {
'tabIndex': '0', 'tabIndex': '0',
'role': 'button' 'role': 'button',
'aria-label': text
})); }));
actionLink.innerText = text; actionLink.innerText = text;
DOM.addDisposableListener(actionLink, DOM.EventType.CLICK, handler); DOM.addDisposableListener(actionLink, DOM.EventType.CLICK, handler);

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
.table-designer-publish-dialog { .table-designer-publish-dialog {
height: 350px; height: calc(100% - 20px);
padding: 10px; padding: 10px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;