diff --git a/packages/calcite-components/src/components/alert/alert.tsx b/packages/calcite-components/src/components/alert/alert.tsx index 57614cd54f4..0773278ee9c 100644 --- a/packages/calcite-components/src/components/alert/alert.tsx +++ b/packages/calcite-components/src/components/alert/alert.tsx @@ -12,7 +12,7 @@ import { Watch, } from "@stencil/core"; import { - getSlotted, + focusFirstTabbable, setRequestedIcon, slotChangeHasAssignedElement, toAriaBoolean, @@ -308,7 +308,6 @@ export class Alert implements OpenCloseComponent, LoadableComponent, T9nComponen onClick={this.closeAlert} onFocusin={this.autoClose ? this.handleKeyBoardFocus : null} onFocusout={this.autoClose ? this.handleKeyBoardBlur : null} - ref={(el) => (this.closeButton = el)} type="button" > @@ -384,16 +383,7 @@ export class Alert implements OpenCloseComponent, LoadableComponent, T9nComponen @Method() async setFocus(): Promise { await componentFocusable(this); - - const alertLinkEl: HTMLCalciteLinkElement = getSlotted(this.el, { selector: "calcite-link" }); - - if (!this.closeButton && !alertLinkEl) { - return; - } else if (alertLinkEl) { - return alertLinkEl.setFocus(); - } else if (this.closeButton) { - this.closeButton.focus(); - } + focusFirstTabbable(this.el); } //-------------------------------------------------------------------------- @@ -435,8 +425,6 @@ export class Alert implements OpenCloseComponent, LoadableComponent, T9nComponen private autoCloseTimeoutId: number = null; - private closeButton: HTMLButtonElement; - private initialOpenTime: number; private lastMouseOverBegin: number;