Skip to content

Commit 6589b54

Browse files
lkostrowskiCopilot
andauthored
Replace deprecated @react/auto-id with react18 useId hook (#6557)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent f7f7b33 commit 6589b54

7 files changed

Lines changed: 14 additions & 44 deletions

File tree

.changeset/khaki-towns-begin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"saleor-dashboard": patch
3+
---
4+
5+
Removed deprecated @reach/auto-id dependency and replaced it with built-in React useId hook. This is purely technical change.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
"@material-ui/styles": "^4.11.5",
8787
"@radix-ui/react-portal": "^1.1.10",
8888
"@radix-ui/react-radio-group": "^1.3.8",
89-
"@reach/auto-id": "^0.16.0",
9089
"@react-editor-js/core": "2.1.0",
9190
"@saleor/macaw-ui": "npm:@saleor/macaw-ui@0.7.4",
9291
"@saleor/macaw-ui-next": "npm:@saleor/macaw-ui@1.4.2",

pnpm-lock.yaml

Lines changed: 0 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/RichTextEditor/RichTextEditor.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { type LogLevels, type OutputData } from "@editorjs/editorjs";
22
import { FormControl, FormHelperText } from "@material-ui/core";
3-
import { useId } from "@reach/auto-id";
43
import { type EditorCore, type Props as ReactEditorJSProps } from "@react-editor-js/core";
54
import { Box } from "@saleor/macaw-ui-next";
65
import clsx from "clsx";
@@ -40,7 +39,8 @@ const RichTextEditor = ({
4039
...props
4140
}: RichTextEditorProps) => {
4241
const classes = useStyles({});
43-
const id = useId(defaultId);
42+
const generatedId = React.useId();
43+
const id = defaultId ?? generatedId;
4444
const ref = React.useRef<EditorCore | null>(null);
4545
const [isFocused, setIsFocused] = React.useState(false);
4646
const [hasValue, setHasValue] = React.useState(false);
@@ -60,7 +60,7 @@ const RichTextEditor = ({
6060
return (editorRef.current = editor);
6161
}
6262
}, []);
63-
// We need to render FormControl first to get id from @reach/auto-id
63+
// Wait until after the initial render before running rerender-dependent editor updates.
6464
const hasRendered = useHasRendered();
6565

6666
// EditorJS does not rerender when default value changes,

src/components/RichTextEditor/RichTextEditorContent.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type LogLevels } from "@editorjs/editorjs";
2-
import { useId } from "@reach/auto-id";
32
import clsx from "clsx";
3+
import { useId } from "react";
44
import { createReactEditorJS } from "react-editor-js";
55

66
import { tools } from "./consts";
@@ -21,8 +21,9 @@ const RichTextEditorContent = ({
2121
...props
2222
}: RichTextEditorContentProps) => {
2323
const classes = useStyles({});
24-
const id = useId(defaultId);
25-
// We need to render FormControl first to get id from @reach/auto-id
24+
const generatedId = useId();
25+
const id = defaultId ?? generatedId;
26+
// Delay EditorJS rendering until after mount to avoid client-only rendering issues.
2627
const hasRendered = useHasRendered();
2728

2829
if (!hasRendered) {

src/orders/components/OrderGrantRefundPage/components/ShippingInluded.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { formatMoneyAmount } from "@dashboard/components/Money";
22
import useLocale from "@dashboard/hooks/useLocale";
33
import { type IMoney } from "@dashboard/utils/intl";
4-
import { useId } from "@reach/auto-id";
54
import { Box, Skeleton, Text, Toggle } from "@saleor/macaw-ui-next";
5+
import { useId } from "react";
66
import { FormattedMessage } from "react-intl";
77

88
import { useGrantRefundContext } from "../context";

src/orders/components/OrderSendRefundPage/components/TransactionCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {
66
TransactionActionEnum,
77
type TransactionItemFragment,
88
} from "@dashboard/graphql";
9-
import { useId } from "@reach/auto-id";
109
import { Button, makeStyles } from "@saleor/macaw-ui";
1110
import { Text } from "@saleor/macaw-ui-next";
1211
import * as React from "react";
12+
import { useId } from "react";
1313
import { FormattedMessage, useIntl } from "react-intl";
1414

1515
import OrderTransaction from "../../OrderTransaction";

0 commit comments

Comments
 (0)