Skip to content

Commit 1b5ff9e

Browse files
Fix displaying for large dialogs (#12052)
Signed-off-by: Jonah Iden <[email protected]> Co-authored-by: Paul Maréchal <[email protected]>
1 parent 00564d6 commit 1b5ff9e

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

Diff for: examples/api-samples/src/browser/menu/sample-menu-contribution.ts

+41-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
// *****************************************************************************
1616

17-
import { QuickInputService } from '@theia/core/lib/browser';
17+
import { ConfirmDialog, QuickInputService } from '@theia/core/lib/browser';
1818
import {
1919
Command, CommandContribution, CommandRegistry, MAIN_MENU_BAR,
2020
MenuContribution, MenuModelRegistry, MenuNode, MessageService, SubMenuOptions
@@ -29,6 +29,14 @@ const SampleCommand2: Command = {
2929
id: 'sample-command2',
3030
label: 'Sample Command2'
3131
};
32+
const SampleCommandConfirmDialog: Command = {
33+
id: 'sample-command-confirm-dialog',
34+
label: 'Sample Confirm Dialog'
35+
};
36+
const SampleComplexCommandConfirmDialog: Command = {
37+
id: 'sample-command-complex-confirm-dialog',
38+
label: 'Sample Complex Confirm Dialog'
39+
};
3240
const SampleCommandWithProgressMessage: Command = {
3341
id: 'sample-command-with-progress',
3442
label: 'Sample Command With Progress Message'
@@ -63,6 +71,38 @@ export class SampleCommandContribution implements CommandContribution {
6371
alert('This is sample command2!');
6472
}
6573
});
74+
commands.registerCommand(SampleCommandConfirmDialog, {
75+
execute: async () => {
76+
const choice = await new ConfirmDialog({
77+
title: 'Sample Confirm Dialog',
78+
msg: 'This is a sample with lots of text:' + Array(100)
79+
.fill(undefined)
80+
.map((element, index) => `\n\nExtra line #${index}`)
81+
.join('')
82+
}).open();
83+
this.messageService.info(`Sample confirm dialog returned with: \`${JSON.stringify(choice)}\``);
84+
}
85+
});
86+
commands.registerCommand(SampleComplexCommandConfirmDialog, {
87+
execute: async () => {
88+
const mainDiv = document.createElement('div');
89+
for (const color of ['#FF00007F', '#00FF007F', '#0000FF7F']) {
90+
const innerDiv = document.createElement('div');
91+
innerDiv.textContent = 'This is a sample with lots of text:' + Array(50)
92+
.fill(undefined)
93+
.map((_, index) => `\n\nExtra line #${index}`)
94+
.join('');
95+
innerDiv.style.backgroundColor = color;
96+
innerDiv.style.padding = '5px';
97+
mainDiv.appendChild(innerDiv);
98+
}
99+
const choice = await new ConfirmDialog({
100+
title: 'Sample Confirm Dialog',
101+
msg: mainDiv
102+
}).open();
103+
this.messageService.info(`Sample confirm dialog returned with: \`${JSON.stringify(choice)}\``);
104+
}
105+
});
66106
commands.registerCommand(SampleQuickInputCommand, {
67107
execute: async () => {
68108
const result = await this.quickInputService.input({

Diff for: packages/core/src/browser/style/dialog.css

+7-1
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,17 @@
6565
align-items: stretch;
6666
position: relative;
6767
padding: calc(var(--theia-ui-padding)*2);
68+
white-space: pre-line;
69+
max-height: 50vh;
70+
overflow-y: auto;
71+
}
72+
73+
.p-Widget.dialogOverlay .dialogContent > * {
74+
height: 100%;
6875
}
6976

7077
.p-Widget.dialogOverlay .dialogControl {
7178
padding: calc(var(--theia-ui-padding)*2);
72-
padding-top: 0px;
7379
display: flex;
7480
flex-direction: row;
7581
align-content: right;

0 commit comments

Comments
 (0)