WIP accessibility: still need to react on aria-attributes in updated, as stuff set by external label (et-description with for attribute) happens after connectedCallback

This commit is contained in:
ralf 2024-04-26 14:47:01 +02:00
parent e9d366aa98
commit 219abb15f7

View File

@ -220,6 +220,16 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
// set aria-label and -description fallbacks (done here and not in updated to ensure reliable fallback order)
if (!this.ariaLabel) this.ariaLabel = this.label || this.placeholder || this.statustext;
if (!this.ariaDescription) this.ariaDescription = this.helpText || (this.statustext !== this.ariaLabel ? this.statustext : '');
this._setAriaAttributes();
}
/**
* Set aria-attributes on our input node
*
* @protected
*/
protected _setAriaAttributes()
{
// pass them on to input-node, if we have one / this.getInputNode() returns one
const input = this.getInputNode();
if (input)
@ -264,6 +274,12 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
// Base off this.value, not this.getValue(), to ignore readonly
this.classList.toggle("hasValue", !(this.value == null || this.value == ""));
}
// pass aria-attributes to our input node
if (changedProperties.has('ariaLabel') || changedProperties.has('ariaDescription'))
{
this._setAriaAttributes();
}
}
/**