Skip to content

Commit c960403

Browse files
committed
Fixed text disappearance in input form.
1 parent f5a419e commit c960403

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/CodeSnippetInputDialog.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,24 @@ export function CodeSnippetInputDialog(
7474
}
7575
}
7676

77+
const body: InputHandler = new InputHandler(tags);
78+
79+
return showInputDialog(tags, idx, codeSnippetWidget, code, body);
80+
}
81+
82+
/**
83+
* This function creates the actual input form and processes the inputs given.
84+
*/
85+
export function showInputDialog(
86+
tags: string[],
87+
idx: number,
88+
codeSnippetWidget: CodeSnippetWidget,
89+
code: string[],
90+
body: InputHandler
91+
): Promise<Contents.IModel | null> {
7792
return showCodeSnippetForm({
7893
title: 'Save Code Snippet',
79-
body: new InputHandler(tags),
80-
// focusNodeSelector: 'input',
94+
body: body,
8195
buttons: [
8296
CodeSnippetForm.cancelButton(),
8397
CodeSnippetForm.okButton({ label: 'Save' })
@@ -88,7 +102,7 @@ export function CodeSnippetInputDialog(
88102
}
89103

90104
if (validateForm(result) === false) {
91-
return CodeSnippetInputDialog(codeSnippetWidget, code, idx); // This works but it wipes out all the data they entered previously...
105+
showInputDialog(tags, idx, codeSnippetWidget, code, body);
92106
} else {
93107
if (idx === -1) {
94108
idx = codeSnippetWidget.codeSnippetWidgetModel.snippets.length;
@@ -232,7 +246,7 @@ export function validateForm(
232246
status = false;
233247
}
234248
if (language === '') {
235-
message += 'Language must be filled out';
249+
message += 'Language must be filled out\n';
236250
status = false;
237251
}
238252
if (!SUPPORTED_LANGUAGES.includes(language)) {
@@ -319,7 +333,7 @@ class Private {
319333
name.onblur = Private.handleOnBlur;
320334

321335
const descriptionTitle = document.createElement('label');
322-
descriptionTitle.textContent = 'Description (required)';
336+
descriptionTitle.textContent = 'Description';
323337
const description = document.createElement('input');
324338
description.className = CODE_SNIPPET_DIALOG_INPUT;
325339
description.required = true;

0 commit comments

Comments
 (0)