Skip to content

Commit

Permalink
dialog: add placeholder option (#12244)
Browse files Browse the repository at this point in the history
The commit adds support for passing a `placeholder` option to the `SingleTextInputDialog` which was previously not possible without having to extend the implementation.

Signed-off-by: vince-fugnitto <[email protected]>
  • Loading branch information
vince-fugnitto authored Mar 1, 2023
1 parent d2f9a7a commit f7ef6b5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/core/src/browser/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ export async function confirmExitWithOrWithoutSaving(captionsToSave: string[], p
export class SingleTextInputDialogProps extends DialogProps {
readonly confirmButtonLabel?: string;
readonly initialValue?: string;
readonly placeholder?: string;
readonly initialSelectionRange?: {
start: number
end: number
Expand All @@ -499,6 +500,7 @@ export class SingleTextInputDialog extends AbstractDialog<string> {
this.inputField.className = 'theia-input';
this.inputField.spellcheck = false;
this.inputField.setAttribute('style', 'flex: 0;');
this.inputField.placeholder = props.placeholder || '';
this.inputField.value = props.initialValue || '';
if (props.initialSelectionRange) {
this.inputField.setSelectionRange(
Expand Down
3 changes: 2 additions & 1 deletion packages/debug/src/browser/console/debug-console-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ export class DebugVariable extends ExpressionContainer {
}
const input = new SingleTextInputDialog({
title: nls.localize('theia/debug/debugVariableInput', 'Set {0} Value', this.name),
initialValue: this.value
initialValue: this.value,
placeholder: nls.localizeByDefault('Value')
});
const newValue = await input.open();
if (newValue) {
Expand Down
3 changes: 2 additions & 1 deletion packages/debug/src/browser/view/debug-watch-expression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export class DebugWatchExpression extends ExpressionItem {
async open(): Promise<void> {
const input = new SingleTextInputDialog({
title: nls.localizeByDefault('Edit Expression'),
initialValue: this.expression
initialValue: this.expression,
placeholder: nls.localizeByDefault('Expression to watch')
});
const newValue = await input.open();
if (newValue !== undefined) {
Expand Down
2 changes: 2 additions & 0 deletions packages/workspace/src/browser/workspace-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export class WorkspaceCommandContribution implements CommandContribution {
title: nls.localizeByDefault('New File'),
parentUri: parentUri,
initialValue: vacantChildUri.path.base,
placeholder: nls.localize('theia/workspace/newFilePlaceholder', 'File Name'),
validate: name => this.validateFileName(name, parent, true)
}, this.labelProvider);

Expand All @@ -261,6 +262,7 @@ export class WorkspaceCommandContribution implements CommandContribution {
title: nls.localizeByDefault('New Folder'),
parentUri: parentUri,
initialValue: vacantChildUri.path.base,
placeholder: nls.localize('theia/workspace/newFolderPlaceholder', 'Folder Name'),
validate: name => this.validateFileName(name, parent, true)
}, this.labelProvider);
dialog.open().then(async name => {
Expand Down

0 comments on commit f7ef6b5

Please sign in to comment.