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
1 change: 1 addition & 0 deletions src/components/layout/LayoutSlots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export const PageContent = styled.main`
grid-area: ${PageGridArea.main};

padding: ${cssVar('dimension-space-300')};
isolation: isolate; // Prevent content z-index values from escaping and overlapping a sticky PageHeader
`;
PageContent.displayName = 'PageContent';

Expand Down
2 changes: 2 additions & 0 deletions src/components/layout/header/page-header/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const StyledPageHeader = styled(StyledHeaderBase)`

&[data-scroll-behavior='${PageHeaderScrollBehavior.collapse}'] {
position: sticky;
z-index: 1; // Ensure the page header is showing over the content when sticky
// The top position is the target height from which we remove the total height and the top margin
top: calc(
${cssVar('layout-page-header-sizes-height-collapsed')} - var(--page-header-total-height) -
Expand All @@ -88,6 +89,7 @@ const StyledPageHeader = styled(StyledHeaderBase)`

&[data-scroll-behavior='${PageHeaderScrollBehavior.sticky}'] {
position: sticky;
z-index: 1; // Ensure the page header is showing over the content when sticky
top: 0;
}
`;
Expand Down
71 changes: 71 additions & 0 deletions stories/layout/Layout-stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import styled from '@emotion/styled';
import type { Meta, StoryObj } from '@storybook/react-vite';
import {
BadgeSeverity,
Button,
cssVar,
DropdownMenu,
Expand All @@ -37,6 +38,7 @@ import {
LinkStandalone,
LogoSonarQubeServer,
Text,
TextInput,
} from '../../src';
import { AsideSize } from '../../src/components/layout/LayoutTypes';
import { PageHeaderScrollBehavior } from '../../src/components/layout/header/common/HeaderTypes';
Expand Down Expand Up @@ -167,6 +169,20 @@ export const Default: Story = {
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum.
</p>
<StackingTestArea>
<TextInput label="Input (no z-index)" />
<HighZIndexBox />
<IsolatedBox />
<TransformBox />
<BadgeSeverity
ariaLabel="Badge (no z-index)"
quality="Badge (no z-index)"
severity="critical"
/>
<DropdownMenu items={<DropdownMenu.ItemButton>An action</DropdownMenu.ItemButton>}>
<Button>Dropdown (portaled)</Button>
</DropdownMenu>
</StackingTestArea>
<div
style={{
display: 'flex',
Expand Down Expand Up @@ -353,6 +369,61 @@ const List = styled.ul`
}
`;

const StackingTestArea = styled.div`
display: flex;
flex-wrap: wrap;
gap: 16px;
align-items: flex-start;
margin-top: 32px;
margin-bottom: 32px;
`;

function HighZIndexBox() {
return (
<div
style={{
position: 'relative',
zIndex: 9999,
padding: '12px 16px',
background: 'salmon',
borderRadius: '8px',
fontWeight: 'bold',
}}>
z-index: 9999
</div>
);
}

function IsolatedBox() {
return (
<div
style={{
isolation: 'isolate',
padding: '12px 16px',
background: 'lightblue',
borderRadius: '8px',
}}>
<div style={{ position: 'relative', zIndex: 9999 }}>
isolation: isolate (child z-index: 9999)
</div>
</div>
);
}

function TransformBox() {
return (
<div
style={{
transform: 'translateY(0)',
padding: '12px 16px',
background: 'lightgreen',
borderRadius: '8px',
}}>
<div style={{ position: 'relative', zIndex: 9999 }}>transform (child z-index: 9999)</div>
</div>
);
}

function getRandomColor() {
return `hsl(${Math.random() * 360}, 100%, 75%)`;
}
Expand Down
Loading