adds limit on issue reporter description (#208346)

This commit is contained in:
Justin Chen 2024-03-21 16:51:06 -07:00 committed by GitHub
parent 774f610801
commit adfa191fec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -83,6 +83,7 @@ export default (): string => `
<textarea name="description" id="description" placeholder="${escape(localize('details', "Please enter details."))}" required></textarea> <textarea name="description" id="description" placeholder="${escape(localize('details', "Please enter details."))}" required></textarea>
</div> </div>
<div id="description-empty-error" class="validation-error hidden" role="alert">${escape(localize('descriptionEmptyValidation', "A description is required."))}</div> <div id="description-empty-error" class="validation-error hidden" role="alert">${escape(localize('descriptionEmptyValidation', "A description is required."))}</div>
<div id="description-short-error" class="validation-error hidden" role="alert">${escape(localize('descriptionTooShortValidation', "Please provide a longer description."))}</div>
</div> </div>
<div class="system-info" id="block-container"> <div class="system-info" id="block-container">

View file

@ -924,13 +924,24 @@ export class IssueReporter extends Disposable {
private validateInput(inputId: string): boolean { private validateInput(inputId: string): boolean {
const inputElement = (<HTMLInputElement>this.getElementById(inputId)); const inputElement = (<HTMLInputElement>this.getElementById(inputId));
const inputValidationMessage = this.getElementById(`${inputId}-empty-error`); const inputValidationMessage = this.getElementById(`${inputId}-empty-error`);
const descriptionShortMessage = this.getElementById(`description-short-error`);
if (!inputElement.value) { if (!inputElement.value) {
inputElement.classList.add('invalid-input'); inputElement.classList.add('invalid-input');
inputValidationMessage?.classList.remove('hidden'); inputValidationMessage?.classList.remove('hidden');
descriptionShortMessage?.classList.add('hidden');
return false; return false;
} else { } else if (inputId === 'description' && inputElement.value.length < 10) {
inputElement.classList.add('invalid-input');
descriptionShortMessage?.classList.remove('hidden');
inputValidationMessage?.classList.add('hidden');
return false;
}
else {
inputElement.classList.remove('invalid-input'); inputElement.classList.remove('invalid-input');
inputValidationMessage?.classList.add('hidden'); inputValidationMessage?.classList.add('hidden');
if (inputId === 'description') {
descriptionShortMessage?.classList.add('hidden');
}
return true; return true;
} }
} }