mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
Revert using tooltip in appA11yTitle directive (#17787)
* revert using tooltip in title directive * add back tooltip delay from revert * add back label to carousel buttons * fix documentation that does not need reverted * remove unnecessary label attr
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
*ngIf="state === SetupExtensionState.Loading"
|
||||
class="bwi bwi-spinner bwi-spin bwi-3x tw-text-muted"
|
||||
aria-hidden="true"
|
||||
[title]="'loading' | i18n"
|
||||
[appA11yTitle]="'loading' | i18n"
|
||||
></i>
|
||||
|
||||
<section *ngIf="state === SetupExtensionState.NeedsExtension" class="tw-text-center tw-mt-4">
|
||||
|
||||
@@ -1,38 +1,22 @@
|
||||
import { Directive, effect, ElementRef, inject } from "@angular/core";
|
||||
|
||||
import { TooltipDirective } from "../tooltip/tooltip.directive";
|
||||
import { Directive, effect, ElementRef, input } from "@angular/core";
|
||||
|
||||
import { setA11yTitleAndAriaLabel } from "./set-a11y-title-and-aria-label";
|
||||
|
||||
/**
|
||||
* @deprecated This function is deprecated in favor of `bitTooltip`.
|
||||
* Please use `bitTooltip` instead.
|
||||
*
|
||||
* Directive that provides accessible tooltips by internally using TooltipDirective.
|
||||
* This maintains the appA11yTitle API while leveraging the enhanced tooltip functionality.
|
||||
*/
|
||||
@Directive({
|
||||
selector: "[appA11yTitle]",
|
||||
hostDirectives: [
|
||||
{
|
||||
directive: TooltipDirective,
|
||||
inputs: ["bitTooltip: appA11yTitle", "tooltipPosition"],
|
||||
},
|
||||
],
|
||||
})
|
||||
export class A11yTitleDirective {
|
||||
private readonly elementRef = inject(ElementRef<HTMLElement>);
|
||||
private readonly tooltipDirective = inject(TooltipDirective);
|
||||
readonly title = input.required<string>({ alias: "appA11yTitle" });
|
||||
|
||||
constructor() {
|
||||
const originalAriaLabel = this.elementRef.nativeElement.getAttribute("aria-label");
|
||||
constructor(private el: ElementRef) {
|
||||
const originalTitle = this.el.nativeElement.getAttribute("title");
|
||||
const originalAriaLabel = this.el.nativeElement.getAttribute("aria-label");
|
||||
|
||||
// setting aria-label as a workaround for testing purposes. Should be removed once tests are updated to check element content.
|
||||
effect(() => {
|
||||
setA11yTitleAndAriaLabel({
|
||||
element: this.elementRef.nativeElement,
|
||||
title: undefined,
|
||||
label: originalAriaLabel ?? this.tooltipDirective.tooltipContent(),
|
||||
element: this.el.nativeElement,
|
||||
title: originalTitle ?? this.title(),
|
||||
label: originalAriaLabel ?? this.title(),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import { TooltipPositionIdentifier, tooltipPositions } from "./tooltip-positions
|
||||
import { TooltipComponent, TOOLTIP_DATA } from "./tooltip.component";
|
||||
|
||||
export const TOOLTIP_DELAY_MS = 800;
|
||||
|
||||
/**
|
||||
* Directive to add a tooltip to any element. The tooltip content is provided via the `bitTooltip` input.
|
||||
* The position of the tooltip can be set via the `tooltipPosition` input. Default position is "above-center".
|
||||
|
||||
Reference in New Issue
Block a user