Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions packages/react/src/ActionMenu/ActionMenu.features.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import type {StoryObj} from '@storybook/react-vite'
import {ActionMenu} from '.'
import {ActionList} from '../ActionList'
import {
Expand Down Expand Up @@ -137,6 +138,43 @@ export const MultiSelect = () => {
)
}

export const MultiSelectWithLongValues: StoryObj = {
render: function MultiSelectWithLongValues() {
const [options, setOptions] = React.useState([
{name: 'Show code folding buttons next to all collapsible blocks of code in the editor', selected: true},
{name: 'Wrap long lines of code to fit within the available width of the editor', selected: false},
{name: 'Center the editor content to keep code readable on wide screens', selected: false},
])

return (
<ActionMenu>
<ActionMenu.Button>Display</ActionMenu.Button>
<ActionMenu.Overlay width="medium">
<ActionList selectionVariant="multiple">
{options.map(option => (
<ActionList.Item
key={option.name}
selected={option.selected}
onSelect={() => {
setOptions(previousOptions =>
previousOptions.map(previousOption =>
previousOption.name === option.name
? {...previousOption, selected: !previousOption.selected}
: previousOption,
),
)
}}
>
{option.name}
</ActionList.Item>
))}
</ActionList>
</ActionMenu.Overlay>
</ActionMenu>
)
},
}

export const InactiveItems = () => (
<ActionMenu>
<ActionMenu.Button>Open menu</ActionMenu.Button>
Expand Down
40 changes: 40 additions & 0 deletions packages/react/src/SelectPanel/SelectPanel.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,46 @@ export const MultiSelect = () => {
)
}

export const MultiSelectWithLongValues = () => {
const longItems = [
{id: 1, text: 'Enhancement requests that improve the experience for new contributors'},
{id: 2, text: 'Bugs that prevent users from completing their most important workflows'},
{id: 3, text: 'Good first issues with detailed instructions and support from maintainers'},
]
const [selected, setSelected] = useState<ItemInput[]>(longItems.slice(0, 1))
const [filter, setFilter] = useState('')
const [open, setOpen] = useState(false)
const filteredItems = longItems.filter(item => item.text.toLowerCase().startsWith(filter.toLowerCase()))

return (
<FormControl>
<FormControl.Label>Labels</FormControl.Label>
<SelectPanel
title="Select labels"
placeholder="Select labels"
subtitle="Use labels to organize issues and pull requests"
renderAnchor={anchorProps => (
<Button trailingAction={TriangleDownIcon} {...anchorProps} aria-haspopup="dialog">
Select labels
</Button>
)}
open={open}
onOpenChange={setOpen}
items={filteredItems}
selected={selected}
onSelectedChange={setSelected}
onFilterChange={setFilter}
width="medium"
message={
filteredItems.length === 0
? {variant: 'empty', title: 'No labels found', body: 'Try a different search term'}
: undefined
}
/>
</FormControl>
)
}

export const WithDisabledItem = () => {
const [selected, setSelected] = useState<ItemInput[]>(items.slice(1, 3))
const [filter, setFilter] = useState('')
Expand Down
Loading