diff --git a/.changeset/many-suns-promise.md b/.changeset/many-suns-promise.md new file mode 100644 index 00000000000..6b465792c8e --- /dev/null +++ b/.changeset/many-suns-promise.md @@ -0,0 +1,5 @@ +--- +"@primer/react": minor +--- + +Replace `ActionBar` overflow calculations with CSS wrapping approach to improve performance and stability diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-colorblind-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-colorblind-linux.png index ef3267dde68..6af220f5785 100644 Binary files a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-colorblind-linux.png and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-dimmed-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-dimmed-linux.png index 3a19d585a19..b1223a04106 100644 Binary files a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-dimmed-linux.png and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-dimmed-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-high-contrast-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-high-contrast-linux.png index 994ae8599e0..31409602eee 100644 Binary files a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-high-contrast-linux.png and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-linux.png index ef3267dde68..6af220f5785 100644 Binary files a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-linux.png and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-tritanopia-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-tritanopia-linux.png index ef3267dde68..6af220f5785 100644 Binary files a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-tritanopia-linux.png and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-tritanopia-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-colorblind-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-colorblind-linux.png index 4496dfcd203..962d8bdd744 100644 Binary files a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-colorblind-linux.png and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-colorblind-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-high-contrast-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-high-contrast-linux.png index 18fecbaec71..1602e7d1d10 100644 Binary files a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-high-contrast-linux.png and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-high-contrast-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-linux.png index 4496dfcd203..962d8bdd744 100644 Binary files a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-linux.png and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-linux.png differ diff --git a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-tritanopia-linux.png b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-tritanopia-linux.png index 4496dfcd203..962d8bdd744 100644 Binary files a/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-tritanopia-linux.png and b/.playwright/snapshots/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-tritanopia-linux.png differ diff --git a/e2e/components/drafts/ActionBar.test.ts b/e2e/components/drafts/ActionBar.test.ts index c39e4d1a9d0..31e1af1ea65 100644 --- a/e2e/components/drafts/ActionBar.test.ts +++ b/e2e/components/drafts/ActionBar.test.ts @@ -47,12 +47,12 @@ test.describe('ActionBar', () => { }, }) const toolbarButtonSelector = `button[data-component="IconButton"]` - await expect(page.locator(toolbarButtonSelector)).toHaveCount(10) - await page.setViewportSize({width: viewports['primer.breakpoint.xs'], height: 768}) + await expect(page.locator(toolbarButtonSelector).filter({visible: true})).toHaveCount(10) + await page.setViewportSize({width: viewports['primer.breakpoint.xs'] - 64, height: 768}) await page.getByLabel('Task List').waitFor({ state: 'hidden', }) - await expect(page.locator(toolbarButtonSelector)).toHaveCount(8) + await expect(page.locator(toolbarButtonSelector).filter({visible: true})).toHaveCount(8) const moreButtonSelector = page.getByLabel('More Comment box toolbar items') await moreButtonSelector.click() await expect(page.locator('ul[role="menu"] [role="menuitem"]')).toHaveCount(3) diff --git a/packages/react/src/ActionBar/ActionBar.examples.stories.module.css b/packages/react/src/ActionBar/ActionBar.examples.stories.module.css index ba8f3744204..5183a4842a7 100644 --- a/packages/react/src/ActionBar/ActionBar.examples.stories.module.css +++ b/packages/react/src/ActionBar/ActionBar.examples.stories.module.css @@ -12,23 +12,32 @@ .CommentBoxHeader { display: flex; - flex-direction: row; + gap: var(--base-size-16); background-color: var(--bgColor-muted); border-top-left-radius: var(--borderRadius-medium); border-top-right-radius: var(--borderRadius-medium); - justify-content: space-between; } -.CommentBoxHeaderLeft { - width: 100%; - min-width: 0; +.CommentBoxHeaderViewSwitch { + flex-basis: 0; + display: flex; + height: 37px; } -.CommentBoxHeaderRight { - display: flex; - gap: var(--base-size-8); +.CommentBoxHeaderToolbar { + flex: 1; justify-content: flex-end; align-items: center; + min-width: 0; + display: flex; + padding-right: var(--base-size-4); + + .CommentBoxHeaderActionBar { + flex: 1; + justify-content: flex-end; + padding-inline: 0; + overflow: hidden; + } } .DialogContent { @@ -69,3 +78,7 @@ .MultipleActionBarsSection { padding: var(--base-size-16); } + +.OverflowHidden { + overflow: hidden; +} diff --git a/packages/react/src/ActionBar/ActionBar.examples.stories.tsx b/packages/react/src/ActionBar/ActionBar.examples.stories.tsx index 6ef573c6341..dd568fa1cfd 100644 --- a/packages/react/src/ActionBar/ActionBar.examples.stories.tsx +++ b/packages/react/src/ActionBar/ActionBar.examples.stories.tsx @@ -56,14 +56,6 @@ export const WithGroups = () => ( ) -export const TextLabels = () => ( - - - - - -) - export const SmallActionBar = () => ( @@ -128,8 +120,13 @@ export const CommentBox = (props: CommentBoxProps) => { return (
-
- +
+ + +
+ +
+ @@ -148,10 +145,6 @@ export const CommentBox = (props: CommentBoxProps) => { >
-
- - -