Skip to content

Allow Overlay contents to properly grow/shrink #6365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Aug 4, 2025
Merged
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
5 changes: 5 additions & 0 deletions .changeset/sweet-ladybugs-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Add `width: 100%` to `Portal`
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions packages/react/src/ActionList/ActionList.dev.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {Description} from './Description'
import Avatar from '../Avatar'
import {FileDirectoryIcon, HeartFillIcon} from '@primer/octicons-react'
import {Stack} from '../Stack'
import {AnchoredOverlay} from '../AnchoredOverlay'

export default {
title: 'Components/ActionList/Dev',
Expand Down Expand Up @@ -300,3 +301,77 @@ export const ItemLabelStylesWithMixedDescriptions = () => (
</Stack>
</Stack>
)

export const OverlayWrapping = () => {
return (
<div style={{display: 'flex', flexDirection: 'column', gap: '100px'}}>
<div style={{width: '300px', border: 'solid 1px gray'}}>
<ActionList>
<ActionList.Item>[email protected]</ActionList.Item>
<ActionList.Item>
[email protected]
<ActionList.TrailingVisual>
<HeartFillIcon />
</ActionList.TrailingVisual>
</ActionList.Item>
<ActionList.Item>
[email protected]
<ActionList.LeadingVisual>
<HeartFillIcon />
</ActionList.LeadingVisual>
</ActionList.Item>
<ActionList.Item>This is a long item title long long long oh wow</ActionList.Item>
<ActionList.Item>
This is a long item title long long long oh wow
<ActionList.TrailingVisual>
<HeartFillIcon />
</ActionList.TrailingVisual>
</ActionList.Item>
</ActionList>
</div>

<div>
<AnchoredOverlay
open
renderAnchor={props => (
<button type="button" {...props}>
Overlay
</button>
)}
>
<ActionList role="menu">
<ActionList.Item role="menuitem">This menu should grow a bit</ActionList.Item>
</ActionList>
</AnchoredOverlay>
</div>

<div>
<AnchoredOverlay
open
width="small"
renderAnchor={props => (
<button type="button" {...props}>
Overlay
</button>
)}
>
<ActionList role="menu">
<ActionList.Item role="menuitem">This menu should wrap because it has a small size</ActionList.Item>
{/* <ActionList.Item role="menuitem">
[email protected]
<ActionList.TrailingVisual>
<HeartFillIcon />
</ActionList.TrailingVisual>
</ActionList.Item> */}
{/* <ActionList.Item role="menuitem">
[email protected]
<ActionList.LeadingVisual>
<HeartFillIcon />
</ActionList.LeadingVisual>
</ActionList.Item> */}
Copy link
Preview

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented-out code blocks (lines 360-371). If this code is needed for testing, consider creating separate test cases or explaining why it's commented out.

Suggested change
</ActionList.Item> */}
// Removed commented-out code blocks for clarity and adherence to clean code principles.

Copilot uses AI. Check for mistakes.

</ActionList>
</AnchoredOverlay>
</div>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports[`AnchoredOverlay > should render consistently when open 1`] = `
</button>
<div
id="__primerPortalRoot__"
style="position: absolute; top: 0px; left: 0px;"
style="position: absolute; top: 0px; left: 0px; width: 100%;"
>
<div
style="position: relative; z-index: 1;"
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/Overlay/Overlay.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

.Overlay {
position: absolute;
max-width: calc(100vw - 2rem);
width: auto;
min-width: 192px;
height: auto;
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/Portal/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function ensureDefaultPortal() {
defaultPortalContainer.style.position = 'absolute'
defaultPortalContainer.style.top = '0'
defaultPortalContainer.style.left = '0'
defaultPortalContainer.style.width = '100%'
const suitablePortalRoot = document.querySelector('[data-portal-root]')
if (suitablePortalRoot) {
suitablePortalRoot.appendChild(defaultPortalContainer)
Expand Down
Loading