mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
[PM-23816] Revert aria disabled buttons (#15656)
* Revert "[CL-295] Use aria-disabled on buttons (#15009)"
This reverts commit 682f1f83d9.
* fix import
* bring back story fixes
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
import { Signal, effect } from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { fromEvent } from "rxjs";
|
||||
|
||||
/**
|
||||
* a11y helper util used to `aria-disable` elements as opposed to using the HTML `disabled` attr.
|
||||
* - Removes HTML `disabled` attr and replaces it with `aria-disabled="true"`
|
||||
* - Captures click events and prevents them from propagating
|
||||
*/
|
||||
export function ariaDisableElement(element: HTMLElement, isDisabled: Signal<boolean | undefined>) {
|
||||
effect(() => {
|
||||
if (element.hasAttribute("disabled") || isDisabled()) {
|
||||
// Remove native disabled and set aria-disabled. Capture click event
|
||||
element.removeAttribute("disabled");
|
||||
|
||||
element.setAttribute("aria-disabled", "true");
|
||||
}
|
||||
});
|
||||
|
||||
fromEvent(element, "click")
|
||||
.pipe(takeUntilDestroyed())
|
||||
.subscribe((event: Event) => {
|
||||
if (isDisabled()) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,3 +1,2 @@
|
||||
export * from "./aria-disable-element";
|
||||
export * from "./function-to-observable";
|
||||
export * from "./i18n-mock.service";
|
||||
|
||||
Reference in New Issue
Block a user