Skip to content
5 changes: 5 additions & 0 deletions .changeset/chilly-dingos-build.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

chore: fix ActionBar gap issue
8 changes: 5 additions & 3 deletions packages/react/src/ActionBar/ActionBar.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,8 @@ import {useFocusZone, FocusKeys} from '../hooks/useFocusZone'
import styles from './ActionBar.module.css'
import {clsx} from 'clsx'

const ACTIONBAR_ITEM_GAP = 8

type ChildSize = {
text: string
width: number
Expand DownExpand Up@@ -48,7 +50,7 @@ export type ActionBarProps = {

export type ActionBarIconButtonProps = {disabled?: boolean} & IconButtonProps

const MORE_BTN_WIDTH = 86
const MORE_BTN_WIDTH = 32

const getValidChildren = (children: React.ReactNode) => {
return React.Children.toArray(children).filter(child => {
Expand All@@ -61,7 +63,7 @@ const calculatePossibleItems = (childWidthArray: ChildWidthArray, navWidth: numb
let breakpoint = childWidthArray.length // assume all items will fit
let sumsOfChildWidth = 0
for (const [index, childWidth] of childWidthArray.entries()) {
sumsOfChildWidth = sumsOfChildWidth + childWidth.width // + GAP
sumsOfChildWidth += index > 0 ? childWidth.width + ACTIONBAR_ITEM_GAP : childWidth.width
if (sumsOfChildWidth > widthToFit) {
breakpoint = index
break
Expand DownExpand Up@@ -202,7 +204,7 @@ export const ActionBar: React.FC<React.PropsWithChildren<ActionBarProps>> = prop
return (
<ActionBarContext.Provider value={{size, setChildrenWidth}}>
<div ref={navRef} className={clsx(className, styles.Nav)} data-flush={flush}>
<div ref={listRef} role="toolbar" className={styles.List}>
<div ref={listRef} role="toolbar" className={styles.List} style={{gap: `${ACTIONBAR_ITEM_GAP}px`}}>

CopilotAISep 11, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] Inline styles should be avoided in favor of CSS classes. Consider adding the gap value to the CSS module file instead of using inline styles.

Copilot uses AI. Check for mistakes.
{listItems}
{menuItems.length > 0 && (
<ActionMenu>
Expand Down
Loading