Files
ThreadNet-Web/src/accessibility/roving/RovingTabIndexWrapper.tsx
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
855 B
TypeScript
Raw Normal View History

/*
2024-09-09 14:57:16 +01:00
Copyright 2024 New Vector Ltd.
2020-07-15 04:26:10 +01:00
Copyright 2020 The Matrix.org Foundation C.I.C.
2024-09-09 14:57:16 +01:00
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
2020-07-15 04:26:10 +01:00
*/
2024-11-13 18:23:37 +05:30
import React, { ReactElement, RefCallback } from "react";
2021-06-29 13:11:58 +01:00
import { useRovingTabIndex } from "../RovingTabIndex";
import { FocusHandler, Ref } from "./types";
interface IProps {
inputRef?: Ref;
children(renderProps: {
onFocus: FocusHandler;
isActive: boolean;
2024-11-13 18:23:37 +05:30
ref: RefCallback<HTMLElement>;
}): ReactElement<any, any>;
}
// Wrapper to allow use of useRovingTabIndex outside of React Functional Components.
2021-06-29 13:11:58 +01:00
export const RovingTabIndexWrapper: React.FC<IProps> = ({ children, inputRef }) => {
const [onFocus, isActive, ref] = useRovingTabIndex(inputRef);
2021-06-29 13:11:58 +01:00
return children({ onFocus, isActive, ref });
};