mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-24 15:27:43 +01:00
31 lines
783 B
TypeScript
31 lines
783 B
TypeScript
import {TextArea as MWCTextArea} from '@material/mwc-textarea';
|
|
import {customElement} from 'lit/decorators.js';
|
|
|
|
@customElement('text-area')
|
|
export default class TextArea extends MWCTextArea {
|
|
private _initialValidationMessage: string | undefined;
|
|
|
|
get nativeValidationMessage() {
|
|
return this.formElement.validationMessage;
|
|
}
|
|
|
|
firstUpdated() {
|
|
if (this.validationMessage) {
|
|
this._initialValidationMessage = this.validationMessage;
|
|
}
|
|
|
|
super.firstUpdated();
|
|
}
|
|
|
|
reportValidity() {
|
|
const isValid = super.reportValidity();
|
|
|
|
// Note(cg): override validationMessage only if no initial message set.
|
|
if (!this._initialValidationMessage && !isValid) {
|
|
this.validationMessage = this.nativeValidationMessage;
|
|
}
|
|
|
|
return isValid;
|
|
}
|
|
}
|