mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-15 01:25:36 -05:00
Add validation error message for inputbox component (#8909)
* add validation error message for inputbox component * addressing comments * remove copying entire definition for InputBoxProperties
This commit is contained in:
@@ -158,12 +158,16 @@ export default class InputBoxComponent extends ComponentBase implements ICompone
|
||||
|
||||
public validate(): Thenable<boolean> {
|
||||
return super.validate().then(valid => {
|
||||
const otherErrorMsg = valid || this.inputElement.value === '' ? undefined : this.validationErrorMessage;
|
||||
valid = valid && this.inputElement.validate();
|
||||
|
||||
// set aria label based on validity of input
|
||||
if (valid) {
|
||||
this.inputElement.setAriaLabel(this.ariaLabel);
|
||||
} else {
|
||||
if (otherErrorMsg) {
|
||||
this.inputElement.showMessage({ type: MessageType.ERROR, content: otherErrorMsg }, true);
|
||||
}
|
||||
if (this.ariaLabel) {
|
||||
this.inputElement.setAriaLabel(nls.localize('period', "{0}. {1}", this.ariaLabel, this.inputElement.inputElement.validationMessage));
|
||||
} else {
|
||||
@@ -329,4 +333,12 @@ export default class InputBoxComponent extends ComponentBase implements ICompone
|
||||
public focus(): void {
|
||||
this.inputElement.focus();
|
||||
}
|
||||
|
||||
public get validationErrorMessage(): string {
|
||||
return this.getPropertyOrDefault<azdata.InputBoxProperties, string>((props) => props.validationErrorMessage, '');
|
||||
}
|
||||
|
||||
public set validationErrorMessage(newValue: string) {
|
||||
this.setPropertyFromUI<azdata.InputBoxProperties, string>((props, value) => props.validationErrorMessage = value, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user