Enable keyboard navigation in member invite list (#7102)

* feat: keyboard nav in share popover

* fix: memoize
This commit is contained in:
Apoorv Mishra
2024-06-22 06:05:05 +05:30
committed by GitHub
parent 5ddc36555d
commit 0f1f0e82c2
13 changed files with 274 additions and 63 deletions

View File

@@ -5,10 +5,11 @@ import * as React from "react";
type Props = React.HTMLAttributes<HTMLDivElement> & {
children: () => React.ReactNode;
onEscape?: (ev: React.KeyboardEvent<HTMLDivElement>) => void;
items: unknown[];
};
function ArrowKeyNavigation(
{ children, onEscape, ...rest }: Props,
{ children, onEscape, items, ...rest }: Props,
ref: React.RefObject<HTMLDivElement>
) {
const handleKeyDown = React.useCallback(
@@ -36,7 +37,10 @@ function ArrowKeyNavigation(
);
return (
<RovingTabIndexProvider options={{ focusOnClick: true, direction: "both" }}>
<RovingTabIndexProvider
options={{ focusOnClick: true, direction: "both" }}
items={items}
>
<div {...rest} onKeyDown={handleKeyDown} ref={ref}>
{children()}
</div>