copy / tooltip fixeS

This commit is contained in:
konnorrogers
2024-07-02 15:19:55 -04:00
parent 5969d4cbdb
commit 38c8017baf
2 changed files with 9 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
import '../icon/icon.js';
import '../tooltip/tooltip.js';
import '../visually-hidden/visually-hidden.js';
import { animateWithClass } from '../../internal/animate.js';
import { classMap } from 'lit/directives/class-map.js';
import { customElement, property, query, state } from 'lit/decorators.js';
@@ -201,6 +202,8 @@ export default class WaCopyButton extends WebAwesomeElement {
?disabled=${this.disabled}
@click=${this.handleCopy}
>
<!-- Render a visually hidden label to appease the accessibility checking gods -->
<wa-visually-hidden>${this.currentLabel}</wa-visually-hidden>
<slot part="copy-icon" name="copy-icon">
<wa-icon library="system" name="copy" variant="regular" fixed-width></wa-icon>
</slot>

View File

@@ -273,7 +273,12 @@ export default class WaTooltip extends WebAwesomeElement {
*/
const currentLabel = newAnchor.getAttribute('aria-labelledby') || '';
if (!currentLabel.match(labelRegex)) {
newAnchor.setAttribute('aria-labelledby', currentLabel + ' ' + this.id);
if (!currentLabel) {
newAnchor.setAttribute('aria-labelledby', this.id);
} else {
newAnchor.setAttribute('aria-labelledby', currentLabel + ' ' + this.id);
}
}
newAnchor.addEventListener('blur', this.handleBlur, { capture: true, signal });