mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Fix input box validation (#14508)
* Fix input box validation * just use return from inputbox validate
This commit is contained in:
@@ -64,7 +64,7 @@ export default class InputBoxComponent extends ComponentBase<azdata.InputBoxProp
|
|||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
content: this.inputElement.inputElement.validationMessage || nls.localize('invalidValueError', "Invalid value"),
|
content: this.inputElement.inputElement.validationMessage || this.validationErrorMessage || nls.localize('invalidValueError', "Invalid value"),
|
||||||
type: MessageType.ERROR
|
type: MessageType.ERROR
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -137,10 +137,8 @@ export default class InputBoxComponent extends ComponentBase<azdata.InputBoxProp
|
|||||||
this._register(input.onDidChange(async e => {
|
this._register(input.onDidChange(async e => {
|
||||||
if (checkOption()) {
|
if (checkOption()) {
|
||||||
this.value = input.value;
|
this.value = input.value;
|
||||||
|
input.hideErrors = false;
|
||||||
await this.validate();
|
await this.validate();
|
||||||
if (input.hideErrors) {
|
|
||||||
input.hideErrors = false;
|
|
||||||
}
|
|
||||||
this.fireEvent({
|
this.fireEvent({
|
||||||
eventType: ComponentEventType.onDidChange,
|
eventType: ComponentEventType.onDidChange,
|
||||||
args: e
|
args: e
|
||||||
@@ -159,17 +157,14 @@ export default class InputBoxComponent extends ComponentBase<azdata.InputBoxProp
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async validate(): Promise<boolean> {
|
public async validate(): Promise<boolean> {
|
||||||
let valid = await super.validate();
|
await super.validate();
|
||||||
const otherErrorMsg = valid || this.inputElement.value === '' ? undefined : this.validationErrorMessage;
|
// Let the input validate handle showing/hiding the error message
|
||||||
valid = valid && this.inputElement.validate();
|
const valid = this.inputElement.validate();
|
||||||
|
|
||||||
// set aria label based on validity of input
|
// set aria label based on validity of input
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.inputElement.setAriaLabel(this.ariaLabel);
|
this.inputElement.setAriaLabel(this.ariaLabel);
|
||||||
} else {
|
} else {
|
||||||
if (otherErrorMsg) {
|
|
||||||
this.inputElement.showMessage({ type: MessageType.ERROR, content: otherErrorMsg }, true);
|
|
||||||
}
|
|
||||||
if (this.ariaLabel) {
|
if (this.ariaLabel) {
|
||||||
this.inputElement.setAriaLabel(nls.localize('period', "{0}. {1}", this.ariaLabel, this.inputElement.inputElement.validationMessage));
|
this.inputElement.setAriaLabel(nls.localize('period', "{0}. {1}", this.ariaLabel, this.inputElement.inputElement.validationMessage));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user