Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b8fd7e

Browse files
chore: fix :first-child warning (#17727)
Fix the following warning: ``` The pseudo class ":first-child" is potentially unsafe when doing server-side rendering. ```
1 parent 902c34c commit 0b8fd7e

File tree

9 files changed

+16
-21
lines changed

9 files changed

+16
-21
lines changed

site/src/components/InputGroup/InputGroup.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,9 @@ export const InputGroup: FC<HTMLProps<HTMLDivElement>> = (props) => {
2525
zIndex: 2,
2626
},
2727

28-
"& > *:first-child": {
28+
"& > *:first-of-type": {
2929
borderTopRightRadius: 0,
3030
borderBottomRightRadius: 0,
31-
32-
"&.MuiFormControl-root .MuiInputBase-root": {
33-
borderTopRightRadius: 0,
34-
borderBottomRightRadius: 0,
35-
},
3631
},
3732

3833
"& > *:last-child": {
@@ -45,7 +40,7 @@ export const InputGroup: FC<HTMLProps<HTMLDivElement>> = (props) => {
4540
},
4641
},
4742

48-
"& > *:not(:first-child):not(:last-child)": {
43+
"& > *:not(:first-of-type):not(:last-child)": {
4944
borderRadius: 0,
5045

5146
"&.MuiFormControl-root .MuiInputBase-root": {

site/src/components/Markdown/Markdown.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -348,19 +348,19 @@ const MarkdownGfmAlert: FC<MarkdownGfmAlertProps> = ({
348348
"[&_p]:m-0 [&_p]:mb-2",
349349

350350
alertType === "important" &&
351-
"border-highlight-purple [&_p:first-child]:text-highlight-purple",
351+
"border-highlight-purple [&_p:first-of-type]:text-highlight-purple",
352352

353353
alertType === "warning" &&
354-
"border-border-warning [&_p:first-child]:text-border-warning",
354+
"border-border-warning [&_p:first-of-type]:text-border-warning",
355355

356356
alertType === "note" &&
357-
"border-highlight-sky [&_p:first-child]:text-highlight-sky",
357+
"border-highlight-sky [&_p:first-of-type]:text-highlight-sky",
358358

359359
alertType === "tip" &&
360-
"border-highlight-green [&_p:first-child]:text-highlight-green",
360+
"border-highlight-green [&_p:first-of-type]:text-highlight-green",
361361

362362
alertType === "caution" &&
363-
"border-highlight-red [&_p:first-child]:text-highlight-red",
363+
"border-highlight-red [&_p:first-of-type]:text-highlight-red",
364364
)}
365365
>
366366
<p className="font-bold">

site/src/components/Table/Table.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ export const TableBody = React.forwardRef<
3636
<tbody
3737
ref={ref}
3838
className={cn(
39-
"[&>tr:first-child>td]:border-t [&>tr>td:first-child]:border-l",
39+
"[&>tr:first-of-type>td]:border-t [&>tr>td:first-of-type]:border-l",
4040
"[&>tr:last-child>td]:border-b [&>tr>td:last-child]:border-r",
41-
"[&>tr:first-child>td:first-child]:rounded-tl-md [&>tr:first-child>td:last-child]:rounded-tr-md",
42-
"[&>tr:last-child>td:first-child]:rounded-bl-md [&>tr:last-child>td:last-child]:rounded-br-md",
41+
"[&>tr:first-of-type>td:first-of-type]:rounded-tl-md [&>tr:first-of-type>td:last-child]:rounded-tr-md",
42+
"[&>tr:last-child>td:first-of-type]:rounded-bl-md [&>tr:last-child>td:last-child]:rounded-br-md",
4343
className,
4444
)}
4545
{...props}

site/src/modules/resources/ResourceCard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const styles = {
1919
borderBottom: 0,
2020
},
2121

22-
"&:first-child": {
22+
"&:first-of-type": {
2323
borderTopLeftRadius: 8,
2424
borderTopRightRadius: 8,
2525
},

site/src/modules/workspaces/WorkspaceTiming/Chart/Chart.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ const styles = {
185185
},
186186
},
187187

188-
"& li:first-child": {
188+
"& li:first-of-type": {
189189
color: theme.palette.text.secondary,
190190
},
191191

site/src/modules/workspaces/WorkspaceTiming/Chart/XAxis.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const XAxisLabel: FC<HTMLProps<HTMLLIElement>> = (props) => {
5656
// Note: This adjustment is not applied to the first element,
5757
// as the 0 label/value is not displayed in the chart.
5858
width: "calc(var(--x-axis-width) * 2)",
59-
"&:not(:first-child)": {
59+
"&:not(:first-of-type)": {
6060
marginLeft: "calc(-1 * var(--x-axis-width))",
6161
},
6262
},

site/src/modules/workspaces/WorkspaceTiming/Chart/YAxis.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const styles = {
3535
flexShrink: 0,
3636
},
3737
section: (theme) => ({
38-
"&:not(:first-child)": {
38+
"&:not(:first-of-type)": {
3939
borderTop: `1px solid ${theme.palette.divider}`,
4040
},
4141
}),

site/src/pages/TemplatePage/TemplateInsightsPage/TemplateInsightsPage.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ const TemplateParametersUsagePanel: FC<TemplateParametersUsagePanelProps> = ({
559559
marginRight: -24,
560560
borderTop: `1px solid ${theme.palette.divider}`,
561561
width: "calc(100% + 48px)",
562-
"&:first-child": {
562+
"&:first-of-type": {
563563
borderTop: 0,
564564
},
565565
gap: 24,

site/src/pages/WorkspacePage/WorkspaceNotifications/Notifications.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const styles = {
123123
lineHeight: "1.5",
124124
borderTop: `1px solid ${theme.palette.divider}`,
125125

126-
"&:first-child": {
126+
"&:first-of-type": {
127127
borderTop: 0,
128128
},
129129
}),

0 commit comments

Comments
 (0)