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

Move flex-shrink: 0 to BaseVisualContainer. #1596

Merged
merged 3 commits into from
Nov 30, 2021
Merged

Move flex-shrink: 0 to BaseVisualContainer. #1596

merged 3 commits into from
Nov 30, 2021

Conversation

dmarcey
Copy link
Contributor

@dmarcey dmarcey commented Nov 10, 2021

This is to address a bug where in a single-select action menu, if an item wraps, it will become misaligned with other items in the list.

Closes #1595

Screenshots

Before:
Image showing misaslignment of the a wrapping item

After:
Image showing list items aligned

Story changes (not included in PR) that I made to repro this scenario:

@dmarcey ➜ /workspaces/react (main ✗) $ git diff src/stories/ActionList.stories.tsx 
diff --git a/src/stories/ActionList.stories.tsx b/src/stories/ActionList.stories.tsx
index 46e21e2c..0c03ccbe 100644
--- a/src/stories/ActionList.stories.tsx
+++ b/src/stories/ActionList.stories.tsx
@@ -106,13 +106,15 @@ const selectListItems = new Array(6).fill(undefined).map((_, i) => {
     id: i
   }
 })
+selectListItems.push({id: 6, text: 'Item with a really really long text value that should wrap'})
 
 export function SingleSelectListStory(): JSX.Element {
   return (
     <>
       <h1>Single Select List</h1>
-      <ErsatzOverlay>
+      <ErsatzOverlay maxWidth="300px">
         <ActionList
+          showItemDividers={true}
           items={selectListItems.map((item, index) => ({
             ...item,
             selected: index === 1

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

@changeset-bot
Copy link

changeset-bot bot commented Nov 10, 2021

🦋 Changeset detected

Latest commit: a7ce0e9

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

This PR includes changesets to release 1 package
Name Type
@primer/components 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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 10, 2021

size-limit report 📦

Path Size
dist/browser.esm.js 57.31 KB (-0.01% 🔽)
dist/browser.umd.js 57.72 KB (-0.01% 🔽)

@@ -295,6 +295,7 @@ const BaseVisualContainer = styled.div<{variant?: ItemProps['variant']; disabled
height: 20px;
width: ${get('space.3')};
margin-right: ${get('space.2')};
flex-shrink: 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of this change, I think we could move the flex-shrink: 0 to an sx prop on the <BaseVisualContainer /> used in <Item /> for single-select action lists, but this seemed like a more correct fix.

Happy to switch to the more targeted approach if we feel like it is safer.

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.

LGTM!

@siddharthkp
Copy link
Member

@dmarcey Sorry for letting this go stale! Do you mind updating this with main and i'll merge this?

This is to address a bug where in a single-select action menu, if an item wraps, it will become misaligned with other items in the list.
@dmarcey
Copy link
Contributor Author

dmarcey commented Nov 30, 2021

@dmarcey Sorry for letting this go stale! Do you mind updating this with main and i'll merge this?

Thanks @siddharthkp! Rebase complete and CI is green!

@siddharthkp siddharthkp merged commit 5c6dc64 into main Nov 30, 2021
@siddharthkp siddharthkp deleted the dmarcey-1595 branch November 30, 2021 14:08
@primer-css primer-css mentioned this pull request Nov 30, 2021
pksjce pushed a commit that referenced this pull request Dec 20, 2021
* Move `flex-shrink: 0` to `BaseVisualContainer`.
This is to address a bug where in a single-select action menu, if an item wraps, it will become misaligned with other items in the list.

* Added changeset

* Updated test snapshots
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.

Misalignment of items in single-select <ActionList /> when an item wraps
2 participants