@descope/web-components-ui 3.1.12 → 3.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8649,7 +8649,7 @@ class RawTooltip extends BaseClass$3 {
8649
8649
  this.tooltip.style.overflow = 'hidden';
8650
8650
  this.tooltip.style.position = 'absolute';
8651
8651
  }
8652
-
8652
+
8653
8653
  #revealWrappedParts() {
8654
8654
  this.tooltip.style.width = '100%';
8655
8655
  this.tooltip.style.height = '100%';
@@ -8674,9 +8674,7 @@ class RawTooltip extends BaseClass$3 {
8674
8674
  #setTooltipTarget() {
8675
8675
  if (!this.children?.length) return;
8676
8676
 
8677
- let ele = Array.from(this.children).find(
8678
- (child) => child !== this.tooltip,
8679
- );
8677
+ let ele = Array.from(this.children).find((child) => child !== this.tooltip);
8680
8678
 
8681
8679
  if (!ele) return;
8682
8680
 
@@ -8696,6 +8694,10 @@ class RawTooltip extends BaseClass$3 {
8696
8694
  return enrichedText;
8697
8695
  }
8698
8696
 
8697
+ get srLabel() {
8698
+ return this.tooltip?.querySelector('[slot="sr-label"]');
8699
+ }
8700
+
8699
8701
  #initTooltipTextComponent() {
8700
8702
  if (!this.overlayContentNode) return;
8701
8703
 
@@ -8706,6 +8708,12 @@ class RawTooltip extends BaseClass$3 {
8706
8708
 
8707
8709
  this.overlayContentNode.appendChild(this.textComponent);
8708
8710
 
8711
+ // An empty sr-label with role="tooltip" fails accessibility checks.
8712
+ // Hide it when there's no tooltip text; vaadin handles populating it when text is present.
8713
+ if (this.srLabel && !this.tooltipText) {
8714
+ this.srLabel.setAttribute('aria-hidden', 'true');
8715
+ }
8716
+
8709
8717
  forwardAttrs(this, this.textComponent, {
8710
8718
  includeAttrs: ['readonly'],
8711
8719
  });
@@ -8741,7 +8749,15 @@ class RawTooltip extends BaseClass$3 {
8741
8749
 
8742
8750
  #updateText(value) {
8743
8751
  if (!this.textComponent) return;
8744
- this.textComponent.textContent = value?.trim();
8752
+ const trimmedValue = (value ?? '').trim();
8753
+ this.textComponent.textContent = trimmedValue;
8754
+ if (this.srLabel) {
8755
+ if (trimmedValue) {
8756
+ this.srLabel.removeAttribute('aria-hidden');
8757
+ } else {
8758
+ this.srLabel.setAttribute('aria-hidden', 'true');
8759
+ }
8760
+ }
8745
8761
  }
8746
8762
 
8747
8763
  attributeChangedCallback(attrName, oldValue, newValue) {
@@ -8753,7 +8769,7 @@ class RawTooltip extends BaseClass$3 {
8753
8769
  }
8754
8770
 
8755
8771
  if (attrName === 'opened') {
8756
- this.#handleTooltipVisibility(attrName, newValue);
8772
+ this.#handleTooltipVisibility();
8757
8773
  }
8758
8774
  }
8759
8775
  }