chore: fix :first-child warning (#17727)

Fix the following warning:

```
The pseudo class ":first-child" is potentially unsafe when doing server-side rendering.
```
This commit is contained in:
Bruno Quaresma
2025-05-09 11:11:00 -03:00
committed by GitHub
parent 902c34cf01
commit 0b8fd7e403
9 changed files with 16 additions and 21 deletions

View File

@ -25,14 +25,9 @@ export const InputGroup: FC<HTMLProps<HTMLDivElement>> = (props) => {
zIndex: 2, zIndex: 2,
}, },
"& > *:first-child": { "& > *:first-of-type": {
borderTopRightRadius: 0, borderTopRightRadius: 0,
borderBottomRightRadius: 0, borderBottomRightRadius: 0,
"&.MuiFormControl-root .MuiInputBase-root": {
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
},
}, },
"& > *:last-child": { "& > *:last-child": {
@ -45,7 +40,7 @@ export const InputGroup: FC<HTMLProps<HTMLDivElement>> = (props) => {
}, },
}, },
"& > *:not(:first-child):not(:last-child)": { "& > *:not(:first-of-type):not(:last-child)": {
borderRadius: 0, borderRadius: 0,
"&.MuiFormControl-root .MuiInputBase-root": { "&.MuiFormControl-root .MuiInputBase-root": {

View File

@ -348,19 +348,19 @@ const MarkdownGfmAlert: FC<MarkdownGfmAlertProps> = ({
"[&_p]:m-0 [&_p]:mb-2", "[&_p]:m-0 [&_p]:mb-2",
alertType === "important" && alertType === "important" &&
"border-highlight-purple [&_p:first-child]:text-highlight-purple", "border-highlight-purple [&_p:first-of-type]:text-highlight-purple",
alertType === "warning" && alertType === "warning" &&
"border-border-warning [&_p:first-child]:text-border-warning", "border-border-warning [&_p:first-of-type]:text-border-warning",
alertType === "note" && alertType === "note" &&
"border-highlight-sky [&_p:first-child]:text-highlight-sky", "border-highlight-sky [&_p:first-of-type]:text-highlight-sky",
alertType === "tip" && alertType === "tip" &&
"border-highlight-green [&_p:first-child]:text-highlight-green", "border-highlight-green [&_p:first-of-type]:text-highlight-green",
alertType === "caution" && alertType === "caution" &&
"border-highlight-red [&_p:first-child]:text-highlight-red", "border-highlight-red [&_p:first-of-type]:text-highlight-red",
)} )}
> >
<p className="font-bold"> <p className="font-bold">

View File

@ -36,10 +36,10 @@ export const TableBody = React.forwardRef<
<tbody <tbody
ref={ref} ref={ref}
className={cn( className={cn(
"[&>tr:first-child>td]:border-t [&>tr>td:first-child]:border-l", "[&>tr:first-of-type>td]:border-t [&>tr>td:first-of-type]:border-l",
"[&>tr:last-child>td]:border-b [&>tr>td:last-child]:border-r", "[&>tr:last-child>td]:border-b [&>tr>td:last-child]:border-r",
"[&>tr:first-child>td:first-child]:rounded-tl-md [&>tr:first-child>td:last-child]:rounded-tr-md", "[&>tr:first-of-type>td:first-of-type]:rounded-tl-md [&>tr:first-of-type>td:last-child]:rounded-tr-md",
"[&>tr:last-child>td:first-child]:rounded-bl-md [&>tr:last-child>td:last-child]:rounded-br-md", "[&>tr:last-child>td:first-of-type]:rounded-bl-md [&>tr:last-child>td:last-child]:rounded-br-md",
className, className,
)} )}
{...props} {...props}

View File

@ -19,7 +19,7 @@ const styles = {
borderBottom: 0, borderBottom: 0,
}, },
"&:first-child": { "&:first-of-type": {
borderTopLeftRadius: 8, borderTopLeftRadius: 8,
borderTopRightRadius: 8, borderTopRightRadius: 8,
}, },

View File

@ -185,7 +185,7 @@ const styles = {
}, },
}, },
"& li:first-child": { "& li:first-of-type": {
color: theme.palette.text.secondary, color: theme.palette.text.secondary,
}, },

View File

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

View File

@ -35,7 +35,7 @@ const styles = {
flexShrink: 0, flexShrink: 0,
}, },
section: (theme) => ({ section: (theme) => ({
"&:not(:first-child)": { "&:not(:first-of-type)": {
borderTop: `1px solid ${theme.palette.divider}`, borderTop: `1px solid ${theme.palette.divider}`,
}, },
}), }),

View File

@ -559,7 +559,7 @@ const TemplateParametersUsagePanel: FC<TemplateParametersUsagePanelProps> = ({
marginRight: -24, marginRight: -24,
borderTop: `1px solid ${theme.palette.divider}`, borderTop: `1px solid ${theme.palette.divider}`,
width: "calc(100% + 48px)", width: "calc(100% + 48px)",
"&:first-child": { "&:first-of-type": {
borderTop: 0, borderTop: 0,
}, },
gap: 24, gap: 24,

View File

@ -123,7 +123,7 @@ const styles = {
lineHeight: "1.5", lineHeight: "1.5",
borderTop: `1px solid ${theme.palette.divider}`, borderTop: `1px solid ${theme.palette.divider}`,
"&:first-child": { "&:first-of-type": {
borderTop: 0, borderTop: 0,
}, },
}), }),