Skip to content

Commit

Permalink
Fix displaying for large dialogs (#12052)
Browse files Browse the repository at this point in the history
Signed-off-by: Jonah Iden <jonah.iden@typefox.io>
Co-authored-by: Paul Maréchal <paul.marechal@ericsson.com>
  • Loading branch information
jonah-iden and paul-marechal authored Jan 18, 2023
1 parent 00564d6 commit 1b5ff9e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
// *****************************************************************************

import { QuickInputService } from '@theia/core/lib/browser';
import { ConfirmDialog, QuickInputService } from '@theia/core/lib/browser';
import {
Command, CommandContribution, CommandRegistry, MAIN_MENU_BAR,
MenuContribution, MenuModelRegistry, MenuNode, MessageService, SubMenuOptions
Expand All @@ -29,6 +29,14 @@ const SampleCommand2: Command = {
id: 'sample-command2',
label: 'Sample Command2'
};
const SampleCommandConfirmDialog: Command = {
id: 'sample-command-confirm-dialog',
label: 'Sample Confirm Dialog'
};
const SampleComplexCommandConfirmDialog: Command = {
id: 'sample-command-complex-confirm-dialog',
label: 'Sample Complex Confirm Dialog'
};
const SampleCommandWithProgressMessage: Command = {
id: 'sample-command-with-progress',
label: 'Sample Command With Progress Message'
Expand Down Expand Up @@ -63,6 +71,38 @@ export class SampleCommandContribution implements CommandContribution {
alert('This is sample command2!');
}
});
commands.registerCommand(SampleCommandConfirmDialog, {
execute: async () => {
const choice = await new ConfirmDialog({
title: 'Sample Confirm Dialog',
msg: 'This is a sample with lots of text:' + Array(100)
.fill(undefined)
.map((element, index) => `\n\nExtra line #${index}`)
.join('')
}).open();
this.messageService.info(`Sample confirm dialog returned with: \`${JSON.stringify(choice)}\``);
}
});
commands.registerCommand(SampleComplexCommandConfirmDialog, {
execute: async () => {
const mainDiv = document.createElement('div');
for (const color of ['#FF00007F', '#00FF007F', '#0000FF7F']) {
const innerDiv = document.createElement('div');
innerDiv.textContent = 'This is a sample with lots of text:' + Array(50)
.fill(undefined)
.map((_, index) => `\n\nExtra line #${index}`)
.join('');
innerDiv.style.backgroundColor = color;
innerDiv.style.padding = '5px';
mainDiv.appendChild(innerDiv);
}
const choice = await new ConfirmDialog({
title: 'Sample Confirm Dialog',
msg: mainDiv
}).open();
this.messageService.info(`Sample confirm dialog returned with: \`${JSON.stringify(choice)}\``);
}
});
commands.registerCommand(SampleQuickInputCommand, {
execute: async () => {
const result = await this.quickInputService.input({
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/browser/style/dialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@
align-items: stretch;
position: relative;
padding: calc(var(--theia-ui-padding)*2);
white-space: pre-line;
max-height: 50vh;
overflow-y: auto;
}

.p-Widget.dialogOverlay .dialogContent > * {
height: 100%;
}

.p-Widget.dialogOverlay .dialogControl {
padding: calc(var(--theia-ui-padding)*2);
padding-top: 0px;
display: flex;
flex-direction: row;
align-content: right;
Expand Down

0 comments on commit 1b5ff9e

Please sign in to comment.