Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "DetailsList has been modified to warn when \"getKey\" and \"selection\" props are passed simultaneously. The \"getKey\" property is never used if a Selection object is passed. Either the \"getKey\" prop from the Selection object is used, or Selection's default getKey implementation (item) => item.key is used, but never the \"getKey\" prop passed to DetailsList. Making \"getKey\" and \"selection\" mutually exclusive DetailsList properties prevents users from making this mistake.",
"packageName": "@fluentui/react",
"email": "alexok@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export class DetailsListDocumentsExample extends React.Component<{}, IDetailsLis
selectionDetails: this._getSelectionDetails(),
});
},
getKey: this._getKey,
});

this.state = {
Expand Down Expand Up @@ -214,7 +215,6 @@ export class DetailsListDocumentsExample extends React.Component<{}, IDetailsLis
compact={isCompactMode}
columns={columns}
selectionMode={SelectionMode.multiple}
getKey={this._getKey}
setKey="multiple"
layoutMode={DetailsListLayoutMode.justified}
isHeaderVisible={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getRTLSafeKeyCode,
classNamesFunction,
memoizeFunction,
warnMutuallyExclusive,
} from '../../Utilities';
import {
CheckboxVisibility,
Expand Down Expand Up @@ -57,6 +58,7 @@ import type { IGroupedList, IGroupDividerProps, IGroupRenderProps, IGroup } from
import type { IListProps } from '../../List';

const getClassNames = classNamesFunction<IDetailsListStyleProps, IDetailsListStyles>();
const COMPONENT_NAME = 'DetailsList';

export interface IDetailsListState {
focusedItemIndex: number;
Expand Down Expand Up @@ -801,6 +803,10 @@ export class DetailsListBase extends React.Component<IDetailsListProps, IDetails
getDerivedStateFromProps: this._getDerivedStateFromProps,
};

warnMutuallyExclusive(COMPONENT_NAME, props, {
selection: 'getKey',
});

this._selection =
props.selection ||
new Selection({
Expand Down