Skip to content

Commit

Permalink
feat: add first item ref prop for pagination focus
Browse files Browse the repository at this point in the history
  • Loading branch information
JBR90 committed Jul 24, 2024
1 parent 0bfd8fa commit f8bfe71
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import React, { ComponentPropsWithoutRef, ElementType } from "react";
import React, {
ComponentPropsWithoutRef,
ElementType,
MutableRefObject,
} from "react";
import styled, { css } from "styled-components";

import { OakFlex, OakBox, OakP, OakHeading, OakSpan } from "@/components/atoms";
Expand Down Expand Up @@ -80,6 +84,7 @@ export type OakUnitListItemProps<C extends ElementType> = {
lessonCount: number | null;
isLegacy: boolean;
href: string;
firstItemRef?: MutableRefObject<HTMLAnchorElement | null> | null | undefined;
} & ComponentPropsWithoutRef<C>;

/**
Expand All @@ -100,6 +105,7 @@ export const OakUnitListItem = <C extends ElementType = "a">(
onClick,
index,
isLegacy,
firstItemRef,
...rest
} = props;

Expand All @@ -115,6 +121,7 @@ export const OakUnitListItem = <C extends ElementType = "a">(
$disabled={disabledOrUnavailable}
href={disabledOrUnavailable ? undefined : href}
onClick={disabledOrUnavailable ? undefined : onClick}
ref={firstItemRef}
{...rest}
>
<StyledOakIndexBox
Expand Down

0 comments on commit f8bfe71

Please sign in to comment.