Skip to content
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

Support overflow scrolling in ActionMenu #3926

Merged
merged 7 commits into from
Dec 19, 2023
Merged

Conversation

strackoverflow
Copy link
Member

@strackoverflow strackoverflow commented Nov 9, 2023

Closes #3486

When looking into #3486, it occurred to me that while we support passing a maxHeight prop, we don't enable overflow scrolling when that prop is provided.

This PR adds an optional overflow prop to Overlay which allows developers to specify the overflow behavior of the menu.

I think ideally we should automatically apply overflow: auto whenever a max height is set (or even for all ActionMenu instances) but at least for now this can unblock this use case without impacting existing usage of Overlay.

Demo
scrolling menu

Changelog

New

Changed

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan

Testing & Reviewing

Merge checklist

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@strackoverflow strackoverflow self-assigned this Nov 9, 2023
Copy link

changeset-bot bot commented Nov 9, 2023

🦋 Changeset detected

Latest commit: b831070

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Nov 9, 2023

size-limit report 📦

Path Size
dist/browser.esm.js 105.56 KB (+0.02% 🔺)
dist/browser.umd.js 106.14 KB (+0.02% 🔺)

@strackoverflow
Copy link
Member Author

Closing in favor of primer/view_components#2383

@strackoverflow
Copy link
Member Author

Re-opening, I meant to close a different PR 😄

@github-actions github-actions bot temporarily deployed to storybook-preview-3926 November 27, 2023 17:01 Inactive
@strackoverflow strackoverflow marked this pull request as ready for review November 28, 2023 15:40
@strackoverflow strackoverflow requested review from a team and pksjce November 28, 2023 15:40
@strackoverflow strackoverflow changed the title Support overflow scrolling when maxHeight is set in ActionMenu Support overflow scrolling in ActionMenu Nov 28, 2023
@siddharthkp
Copy link
Member

siddharthkp commented Dec 1, 2023

I think ideally we should automatically apply overflow: auto whenever a max height is set (or even for all ActionMenu instances)

Same! Are there any risks in doing that? (for example: Overlays that suddenly have an unexpected scroll?)

If we feel more confident, we can enable it just for primer components that internally use Overlay like ActionMenu, Autocomplete, etc.

Copy link
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

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

Looks good!

Left a non blocking comment that we can look at in follow up PR

@strackoverflow
Copy link
Member Author

Are there any risks in doing that? (for example: Overlays that suddenly have an unexpected scroll?)

@siddharthkp this is the exact thing I want to be cautious about. I agree, we can merge this basic step for now to unblock anyone who needs to enable scrolling but we can revisit to make the DX a little better. Thanks!

@github-actions github-actions bot temporarily deployed to storybook-preview-3926 December 12, 2023 18:30 Inactive
@strackoverflow strackoverflow added this pull request to the merge queue Dec 12, 2023
@strackoverflow strackoverflow removed this pull request from the merge queue due to a manual request Dec 12, 2023
@@ -64,7 +65,7 @@ const StyledOverlay = styled.div<StyledOverlayProps>`
max-height: ${props => props.maxHeight && heightMap[props.maxHeight]};
width: ${props => widthMap[props.width || 'auto']};
border-radius: 12px;
overflow: hidden;
${props => (props.overflow ? `overflow: ${props.overflow};` : '')}
Copy link
Member Author

Choose a reason for hiding this comment

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

I just realized we should probably retain the existing overflow behavior if the prop isn't provided so that we don't cause any unexpected side effects. I'll push up a fix for that.

@strackoverflow
Copy link
Member Author

@siddharthkp 👋 would you mind taking another look at this PR? I was about to merge it when I realized that this changed the default overflow behavior of Overlay, which was not intentional.

Let me know if the current diff looks good to merge now!

Copy link
Member

@broccolinisoup broccolinisoup left a comment

Choose a reason for hiding this comment

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

Looks great! ✨

@strackoverflow strackoverflow added this pull request to the merge queue Dec 19, 2023
Merged via the queue into main with commit 4e4c5ec Dec 19, 2023
28 of 29 checks passed
@strackoverflow strackoverflow deleted the action-menu-max-height branch December 19, 2023 03:10
@primer primer bot mentioned this pull request Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ActionMenu overflow when there are too many ActionList items
3 participants