Skip to content

Commit b21d412

Browse files
committed
feat: polish types to be compatible with React 18.3
1 parent 6122274 commit b21d412

File tree

9 files changed

+18
-9
lines changed

9 files changed

+18
-9
lines changed

packages/orbit-components/src/Accordion/AccordionSection/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const AccordionSection = ({
5050
)}
5151

5252
<Slide maxHeight={height} expanded={isExpanded} id={slideId}>
53-
<div ref={ref}>
53+
<div ref={ref as React.RefObject<HTMLDivElement>}>
5454
{children && <SectionContent dataTest={dataTest}>{children}</SectionContent>}
5555
{footer && <SectionFooter dataTest={dataTest}>{footer}</SectionFooter>}
5656
</div>

packages/orbit-components/src/Card/CardSection/components/Expandable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default function Expandable({ expanded, children, slideID }: Props) {
1414

1515
return (
1616
<Slide maxHeight={height} expanded={expanded} id={slideID}>
17-
<div ref={ref}>{children}</div>
17+
<div ref={ref as React.RefObject<HTMLDivElement>}>{children}</div>
1818
</Slide>
1919
);
2020
}

packages/orbit-components/src/Collapse/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const Collapse = ({
105105
</Stack>
106106
</div>
107107
<Slide maxHeight={height} expanded={expanded} id={slideID}>
108-
<div className="my-300 mx-0" ref={node}>
108+
<div className="my-300 mx-0" ref={node as React.RefObject<HTMLDivElement>}>
109109
{children}
110110
</div>
111111
</Slide>

packages/orbit-components/src/InputSelect/index.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ const InputSelect = React.forwardRef<HTMLInputElement, Props>(
272272
id={optionId}
273273
active={activeIdx === idx}
274274
isSelected={isSelected}
275-
ref={optionRef}
275+
ref={optionRef as React.RefObject<HTMLDivElement>}
276276
title={title}
277277
description={description}
278278
prefix={prefix}
@@ -325,7 +325,7 @@ const InputSelect = React.forwardRef<HTMLInputElement, Props>(
325325
id={optionId}
326326
active={!!isLargeMobile && activeIdx === optionIdx}
327327
isSelected={isSelected}
328-
ref={optionRef}
328+
ref={optionRef as React.RefObject<HTMLDivElement>}
329329
title={title}
330330
description={description}
331331
prefix={prefix}
@@ -354,7 +354,7 @@ const InputSelect = React.forwardRef<HTMLInputElement, Props>(
354354
const { title, description, prefix, value: optValue, group } = option;
355355
if (group && !showAll) return null;
356356
idx += 1;
357-
const optionRef = React.createRef() as React.RefObject<HTMLDivElement | null>;
357+
const optionRef = React.createRef() as React.RefObject<HTMLDivElement>;
358358
const optionIdx = idx;
359359
refs[optionIdx] = optionRef;
360360

packages/orbit-components/src/Itinerary/ItinerarySegment/ItinerarySegmentDetail/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ const ItinerarySegmentDetail = ({
7171
ariaLabelledBy={randomId("slide")}
7272
stopClickPropagation={false}
7373
>
74-
<div className="pt-300 cursor-pointer overflow-hidden" ref={slideRef}>
74+
<div
75+
className="pt-300 cursor-pointer overflow-hidden"
76+
ref={slideRef as React.RefObject<HTMLDivElement>}
77+
>
7578
<div
7679
className="px-300 z-default relative py-0"
7780
style={{

packages/orbit-components/src/Modal/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ const Modal = React.forwardRef<Instance, Props>(
9292
if (typeof scrollingElementRef === "function") {
9393
scrollingElementRef(node);
9494
} else {
95+
// @ts-expect-error TODO
9596
// eslint-disable-next-line no-param-reassign
9697
scrollingElementRef.current = node;
9798
}

packages/orbit-components/src/Modal/types.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type Props = Common.Globals &
2121
closable & {
2222
readonly size?: Size;
2323
readonly children: React.ReactNode;
24-
readonly triggerRef?: React.RefObject<HTMLElement | null>;
24+
readonly triggerRef?: React.RefObject<HTMLElement>;
2525
readonly lockScrolling?: boolean;
2626
readonly scrollingElementRef?: React.Ref<HTMLElement | null>;
2727
readonly onClose?: Common.Event<

packages/orbit-components/src/Tile/components/TileExpandable/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ const TileExpandable = ({
8484
/>
8585
)}
8686
<Slide maxHeight={height} expanded={isExpanded} id={slideID} ariaLabelledBy={labelID}>
87-
<TileContent noPadding={noPadding} ref={node} withBorder={hasHeader}>
87+
<TileContent
88+
noPadding={noPadding}
89+
ref={node as React.RefObject<HTMLDivElement>}
90+
withBorder={hasHeader}
91+
>
8892
{children}
8993
</TileContent>
9094
</Slide>

packages/orbit-components/src/utils/mergeRefs/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default function mergeRefs<T = HTMLElement>(
88
if (typeof ref === "function") {
99
ref(value);
1010
} else if (ref != null && typeof ref !== "string") {
11+
// @ts-expect-error expected to be mutable
1112
// eslint-disable-next-line no-param-reassign
1213
ref.current = value;
1314
}

0 commit comments

Comments
 (0)