Skip to content

Commit

Permalink
chore: add type to FocusableElements (#6102)
Browse files Browse the repository at this point in the history
* added type `FocusableElementPromise` to `FocusableElements.ts` file, and made the `startFromContainer` param to optional.
  • Loading branch information
hinzzx authored Nov 30, 2022
1 parent 17e74dd commit 34af8e1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/base/src/util/FocusableElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ import isElementHidden from "./isElementHidden.js";
import isElementClickable from "./isElementClickable.js";
import { instanceOfUI5Element } from "../UI5Element.js";

type FocusableElementPromise = Promise<HTMLElement | null>;

const isFocusTrap = (el: HTMLElement) => {
return el.hasAttribute("data-ui5-focus-trap");
};

const getFirstFocusableElement = async (container: HTMLElement, startFromContainer: boolean): Promise<HTMLElement | null> => {
const getFirstFocusableElement = async (container: HTMLElement, startFromContainer?: boolean): FocusableElementPromise => {
if (!container || isElementHidden(container)) {
return null;
}

return findFocusableElement(container, true, startFromContainer);
};

const getLastFocusableElement = async (container: HTMLElement, startFromContainer: boolean) => {
const getLastFocusableElement = async (container: HTMLElement, startFromContainer?: boolean): FocusableElementPromise => {
if (!container || isElementHidden(container)) {
return null;
}
Expand All @@ -26,7 +28,7 @@ const isElemFocusable = (el: HTMLElement) => {
return el.hasAttribute("data-ui5-focus-redirect") || !isElementHidden(el);
};

const findFocusableElement = async (container: HTMLElement, forward: boolean, startFromContainer?: boolean): Promise<HTMLElement | null> => {
const findFocusableElement = async (container: HTMLElement, forward: boolean, startFromContainer?: boolean): FocusableElementPromise => {
let child: HTMLElement | undefined;

if (container.shadowRoot) {
Expand Down

0 comments on commit 34af8e1

Please sign in to comment.