Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/react-core/src/components/Drawer/DrawerPanelContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps
const hidden = isStatic ? false : !isExpanded;
const [isExpandedInternal, setIsExpandedInternal] = useState(!hidden);
const [isFocusTrapActive, setIsFocusTrapActive] = useState(false);
const [shouldCollapseSpace, setShouldCollapseSpace] = useState(hidden);
const previouslyFocusedElement = useRef(null);
let currWidth: number = 0;
let panelRect: DOMRect;
Expand All @@ -104,6 +105,7 @@ export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps
useEffect(() => {
if (!isStatic && isExpanded) {
setIsExpandedInternal(isExpanded);
setShouldCollapseSpace(false);
}
}, [isStatic, isExpanded]);

Expand Down Expand Up @@ -375,14 +377,21 @@ export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps
onExpand(ev);
}
setIsExpandedInternal(!hidden);
// We also need to collapse the space when the panel is hidden to prevent automation from scrolling to it
if (hidden && ev.nativeEvent.propertyName === 'transform') {
setShouldCollapseSpace(true);
}
if (isValidFocusTrap && ev.nativeEvent.propertyName === 'transform') {
setIsFocusTrapActive((prevIsFocusTrapActive) => !prevIsFocusTrapActive);
}
}
}}
hidden={hidden}
{...((defaultSize || minSize || maxSize) && {
style: boundaryCssVars as React.CSSProperties
{...((defaultSize || minSize || maxSize || shouldCollapseSpace) && {
style: {
...boundaryCssVars,
...(shouldCollapseSpace && { flexBasis: 0 })
} as React.CSSProperties
})}
{...props}
ref={panel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exports[`DrawerPanelContent should match snapshot (auto-generated) 1`] = `
class="pf-v6-c-drawer__panel ''"
hidden=""
id="generated-id"
style="flex-basis: 0px;"
/>
</DocumentFragment>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ exports[`Drawer isExpanded = false and isInline = false and isStatic = false 1`]
class="pf-v6-c-drawer__panel"
hidden=""
id="generated-id"
style="flex-basis: 0px;"
/>
</div>
</div>
Expand Down Expand Up @@ -308,6 +309,7 @@ exports[`Drawer isExpanded = false and isInline = true and isStatic = false 1`]
class="pf-v6-c-drawer__panel"
hidden=""
id="generated-id"
style="flex-basis: 0px;"
/>
</div>
</div>
Expand Down
Loading