Skip to content

Commit

Permalink
Fixes initial check for if menu items should have overflow menu or no…
Browse files Browse the repository at this point in the history
…t; adds new story
  • Loading branch information
TylerJDev committed Dec 27, 2024
1 parent 0f7c157 commit c9b9b55
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 33 additions & 0 deletions packages/react/src/ActionBar/ActionBar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react'
import type {Meta} from '@storybook/react'
import {INITIAL_VIEWPORTS} from '@storybook/addon-viewport'
import ActionBar from '.'
import Text from '../Text'
import {
Expand Down Expand Up @@ -43,6 +44,38 @@ export const Default = () => (
</ActionBar>
)

export const WithOverflowMenu = () => (
<ActionBar aria-label="Toolbar">
<ActionBar.IconButton icon={BoldIcon} aria-label="Bold"></ActionBar.IconButton>
<ActionBar.IconButton icon={ItalicIcon} aria-label="Italic"></ActionBar.IconButton>
<ActionBar.IconButton icon={CodeIcon} aria-label="Code"></ActionBar.IconButton>
<ActionBar.IconButton icon={LinkIcon} aria-label="Link"></ActionBar.IconButton>
<ActionBar.Divider />
<ActionBar.IconButton icon={FileAddedIcon} aria-label="File Added"></ActionBar.IconButton>
<ActionBar.IconButton icon={SearchIcon} aria-label="Search"></ActionBar.IconButton>
<ActionBar.IconButton icon={QuoteIcon} aria-label="Insert Quote"></ActionBar.IconButton>
<ActionBar.IconButton icon={ListUnorderedIcon} aria-label="Unordered List"></ActionBar.IconButton>
<ActionBar.IconButton icon={ListOrderedIcon} aria-label="Ordered List"></ActionBar.IconButton>
<ActionBar.IconButton icon={TasklistIcon} aria-label="Task List"></ActionBar.IconButton>
</ActionBar>
)

WithOverflowMenu.parameters = {
viewport: {
viewports: {
...INITIAL_VIEWPORTS,
narrowScreen: {
name: 'Small Screen',
styles: {
width: '310px',
height: '100%',
},
},
},
defaultViewport: 'narrowScreen',
},
}

export const TextLabels = () => (
<ActionBar aria-label="Toolbar">
<Button>Edit</Button>
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ActionBar/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const overflowEffect = (
const menuItems: Array<React.ReactElement> = []

// First, we check if we can fit all the items with their icons
if (childArray.length > numberOfItemsPossible) {
if (childArray.length >= numberOfItemsPossible) {
/* Below is an accessibility requirement. Never show only one item in the overflow menu.
* If there is only one item left to display in the overflow menu according to the calculation,
* we need to pull another item from the list into the overflow menu.
Expand Down

0 comments on commit c9b9b55

Please sign in to comment.