Skip to content

Commit 9651f18

Browse files
Add actionMenu slot to ListView (#2485)
1 parent 7893f93 commit 9651f18

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

packages/@react-spectrum/list/src/ListViewItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ export function ListViewItem(props) {
118118
UNSAFE_className: listStyles['react-spectrum-ListViewItem-actions'],
119119
isQuiet: true,
120120
density: 'compact'
121-
}
121+
},
122+
actionMenu: {UNSAFE_className: listStyles['react-spectrum-ListViewItem-actionmenu'], isQuiet: true}
122123
}}>
123124
{typeof item.rendered === 'string' ? <Content>{item.rendered}</Content> : item.rendered}
124125
<ClearSlots>

packages/@react-spectrum/list/src/listview.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@
113113
grid-template-columns: auto auto auto 1fr auto auto;
114114
grid-template-rows: 1fr auto;
115115
grid-template-areas:
116-
"checkbox icon image content actions chevron"
117-
"checkbox icon image description actions chevron"
116+
"checkbox icon image content actions actionmenu chevron"
117+
"checkbox icon image description actions actionmenu chevron"
118118
;
119119
align-items: center;
120120
}
@@ -169,6 +169,10 @@
169169
flex-shrink: 0;
170170
}
171171

172+
.react-spectrum-ListViewItem-actionmenu {
173+
grid-area: actionmenu;
174+
}
175+
172176
.react-spectrum-ListView-centeredWrapper {
173177
display: flex;
174178
align-items: center;

packages/@react-spectrum/list/stories/ListView.stories.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {Flex} from '@react-spectrum/layout';
1111
import Folder from '@spectrum-icons/workflow/Folder';
1212
import {Heading, Text} from '@react-spectrum/text';
1313
import {IllustratedMessage} from '@react-spectrum/illustratedmessage';
14+
import Info from '@spectrum-icons/workflow/Info';
1415
import {Item, ListView} from '../';
1516
import {Link} from '@react-spectrum/link';
1617
import MoreSmall from '@spectrum-icons/workflow/MoreSmall';
@@ -174,6 +175,27 @@ storiesOf('ListView', module)
174175
</Item>
175176
</ActionMenu>
176177
)))
178+
.add('actions: ActionGroup + ActionMenu', () =>
179+
renderActionsExample(props => (
180+
<>
181+
<ActionGroup buttonLabelBehavior="hide" {...props} slot="actionGroup">
182+
<Item key="info">
183+
<Info />
184+
<Text>Info</Text>
185+
</Item>
186+
</ActionGroup>
187+
<ActionMenu {...props} slot="actionMenu">
188+
<Item key="add">
189+
<Add />
190+
<Text>Add</Text>
191+
</Item>
192+
<Item key="delete">
193+
<Delete />
194+
<Text>Delete</Text>
195+
</Item>
196+
</ActionMenu>
197+
</>
198+
)))
177199
.add('dynamic items + renderEmptyState', () => (<EmptyTest />))
178200
.add('selectionStyle: highlight', () => (
179201
<ListView width="250px" height={400} selectionStyle="highlight" selectionMode="multiple" items={[...Array(20).keys()].map(k => ({key: k, name: `Item ${k}`}))}>

0 commit comments

Comments
 (0)