Skip to content

Commit 80318c9

Browse files
authored
List: default cursor for items with disabled selection (#35153)
1 parent 661e9bb commit 80318c9

File tree

6 files changed

+28
-3
lines changed

6 files changed

+28
-3
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Use default cursor when selection is disabled",
4+
"packageName": "@fluentui/react-list",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/react-list/library/etc/react-list.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export type ListItemSlots = {
4646
export type ListItemState = ComponentState<ListItemSlots> & {
4747
selectable: boolean;
4848
navigable: boolean;
49+
disabled?: boolean;
4950
};
5051

5152
// @public

packages/react-components/react-list/library/src/components/ListItem/ListItem.types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ export type ListItemProps = ComponentProps<ListItemSlots> & {
2424
/**
2525
* State used in rendering ListItem
2626
*/
27-
export type ListItemState = ComponentState<ListItemSlots> & { selectable: boolean; navigable: boolean };
27+
export type ListItemState = ComponentState<ListItemSlots> & {
28+
selectable: boolean;
29+
navigable: boolean;
30+
disabled?: boolean;
31+
};

packages/react-components/react-list/library/src/components/ListItem/useListItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ export const useListItem_unstable = (
227227
},
228228
root,
229229
checkmark,
230+
disabled: disabledSelection && !onAction,
230231
selectable: isSelectionModeEnabled,
231232
navigable: focusableItems,
232233
};

packages/react-components/react-list/library/src/components/ListItem/useListItemStyles.styles.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ const useStyles = makeStyles({
3838
display: 'flex',
3939
cursor: 'pointer',
4040
},
41+
42+
disabled: {
43+
cursor: 'default',
44+
},
4145
});
4246

4347
/**
@@ -54,6 +58,7 @@ export const useListItemStyles_unstable = (state: ListItemState): ListItemState
5458
listItemClassNames.root,
5559
rootBaseStyles,
5660
(state.selectable || state.navigable) && styles.rootClickableOrSelectable,
61+
state.disabled && styles.disabled,
5762
state.root.className,
5863
);
5964

packages/react-components/react-list/stories/src/List/SingleActionSelectionDifferentPrimary.stories.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,15 @@ export const SingleActionSelectionDifferentPrimary = (): JSXElement => {
4545
selectedItems={selectedItems}
4646
onSelectionChange={(_, data) => setSelectedItems(data.selectedItems)}
4747
>
48-
{items.map(({ name, avatar }) => (
49-
<ListItem key={name} value={name} aria-label={name} onAction={onAction} checkmark={{ 'aria-label': name }}>
48+
{items.map(({ name, avatar }, index) => (
49+
<ListItem
50+
key={name}
51+
value={name}
52+
aria-label={name}
53+
onAction={onAction}
54+
checkmark={{ 'aria-label': name }}
55+
disabledSelection={index === 2}
56+
>
5057
<Persona
5158
name={name}
5259
secondaryText="Available"

0 commit comments

Comments
 (0)