Skip to content

Commit 928b8ba

Browse files
Prevent onSelect callback when menu-list ListItem has property 'disabled' (#3042)
Co-authored-by: Stephen James <sjames@salesforce.com>
1 parent 6ccb1c0 commit 928b8ba

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

components/utilities/menu-list/item.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ declare module '@salesforce/design-system-react/components/utilities/menu-list/i
55
className?: any[] | Record<string, any> | string;
66
checkmark?: boolean;
77
data?: Record<string, any>;
8+
disabled?: boolean;
89
divider?: 'top' | 'bottom';
910
href?: string;
1011
id: string /*.isRequired*/;

components/utilities/menu-list/item.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ListItem extends React.Component {
4242
]),
4343
checkmark: PropTypes.bool,
4444
data: PropTypes.object,
45+
disabled: PropTypes.bool,
4546
divider: PropTypes.oneOf(['top', 'bottom']),
4647
href: PropTypes.string,
4748
id: PropTypes.string.isRequired,
@@ -136,7 +137,7 @@ class ListItem extends React.Component {
136137
EventUtil.trapImmediate(event);
137138
}
138139

139-
if (this.props.onSelect) {
140+
if (this.props.onSelect && !this.props.disabled) {
140141
this.props.onSelect(this.props.index);
141142
}
142143
};

0 commit comments

Comments
 (0)