Skip to content

Commit a88edd6

Browse files
committed
fix(DrawerPanelContent): inert react 19 support
1 parent c9853de commit a88edd6

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

packages/react-core/src/components/Drawer/DrawerPanelContent.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Fragment, useCallback, useContext, useEffect, useRef, useState } from 'react';
1+
import { Fragment, useCallback, useContext, useEffect, useRef, useState, version } from 'react';
22
import styles from '@patternfly/react-styles/css/components/Drawer/drawer';
33
import { css } from '@patternfly/react-styles';
44
import { DrawerColorVariant, DrawerContext } from './Drawer';
@@ -64,6 +64,12 @@ export interface DrawerPanelContentProps extends Omit<React.HTMLProps<HTMLDivEle
6464
let isResizing: boolean = null;
6565
let newSize: number = 0;
6666

67+
/**
68+
* Before React 19, React JSX treats empty string "" as truthy for inert prop.
69+
* @see {@link https://stackoverflow.com/questions/72720469}
70+
*/
71+
const IS_INERT = Number(version.split('.')[0]) >= 19 ? true : ('' as unknown as boolean);
72+
6773
export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps> = ({
6874
className,
6975
id,
@@ -394,7 +400,7 @@ export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps
394400
...((defaultSize || minSize || maxSize) && boundaryCssVars),
395401
...style
396402
}}
397-
{...(shouldCollapseSpace && { inert: '' })}
403+
{...(shouldCollapseSpace && { inert: IS_INERT })}
398404
{...props}
399405
ref={panel}
400406
>

yarn.lock

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17300,15 +17300,6 @@ __metadata:
1730017300
languageName: node
1730117301
linkType: hard
1730217302

17303-
"minimatch@npm:^10.2.2":
17304-
version: 10.2.5
17305-
resolution: "minimatch@npm:10.2.5"
17306-
dependencies:
17307-
brace-expansion: "npm:^5.0.5"
17308-
checksum: 10c0/6bb058bd6324104b9ec2f763476a35386d05079c1f5fe4fbf1f324a25237cd4534d6813ecd71f48208f4e635c1221899bef94c3c89f7df55698fe373aaae20fd
17309-
languageName: node
17310-
linkType: hard
17311-
1731217303
"minimatch@npm:^3.0.2, minimatch@npm:^3.0.4, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2":
1731317304
version: 3.1.2
1731417305
resolution: "minimatch@npm:3.1.2"

0 commit comments

Comments
 (0)