Skip to content

Commit

Permalink
fix: Address validationError tooltip console for outputs (#5088)
Browse files Browse the repository at this point in the history
* reduce console noise on input-text condition
* update voiceover ref comment
  • Loading branch information
KearseTrevor authored Nov 12, 2024
1 parent 0afee53 commit 907c171
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/inputs/input-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ class InputText extends InputInlineHelpMixin(PropertyRequiredMixin(FocusMixin(La
let tooltip = nothing;
if (!this.skeleton) {
if (this.validationError && !this.noValidate) {
// this tooltip is using "announced" since we don't want aria-describedby wire-up which would bury the message in VoiceOver's More Content Available menu
// this tooltip is using "announced" since we don't want aria-describedby wire-up - VoiceOver ignores our message when the input is invalid
tooltip = html`<d2l-tooltip state="error" announced align="start" class="vdiff-target">${this.validationError} <span class="d2l-offscreen">${this.description}</span></d2l-tooltip>`;
} else if (this.instructions) {
tooltip = html`<d2l-tooltip align="start" for="${this._inputId}" delay="1000" class="vdiff-target">${this.instructions}</d2l-tooltip>`;
Expand Down
6 changes: 5 additions & 1 deletion components/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,13 @@ class Tooltip extends RtlMixin(LitElement) {
target = ownerRoot.querySelector(targetSelector);
target = target || ownerRoot?.host?.querySelector(targetSelector);
} else {
console.warn('<d2l-tooltip>: missing required attribute "for"');
const parentNode = this.parentNode;
target = parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? ownerRoot.host : parentNode;

// reduce console pollution since Safari + VO prevents inadequate SR experience for tooltips during form validation when using 'for'
if (!(target.tagName === 'D2L-INPUT-TEXT' && target?.invalid)) {
console.warn('<d2l-tooltip>: missing required attribute "for"');
}
}
return target;
}
Expand Down

0 comments on commit 907c171

Please sign in to comment.