fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

DetailsList selection not updating on items sort

Open j-te opened this issue 7 years ago • 5 comments

Posted as a bug since CodePen / examples do not handle re-selecting.

I believe DetailsList should handle re-sorting of the current selection. This applies to single and multi-select mode. If this isn't agreed as a fix then maybe an example of how to handle it would be handy. For discussion...

Environment Information

  • Package version(s): 6.187.1

Please provide a reproduction of the bug in a codepen:

Default DetailsList CodePen

Actual behavior:

Sorting by column header click does not re-select previous items.

Expected behavior:

Either:

  • a deselect all
  • or re-selection of current items

Priorities and help requested:

Are you willing to submit a PR to fix? (No)

Requested priority: (Normal)

j-te avatar Jun 11 '19 12:06 j-te

@j-te thank you for reporting this issue. We are investigating.

Rajeev-K avatar Jun 11 '19 16:06 Rajeev-K

Currently, it looks like default behavior is to maintain selection by index which is not desirable for obvious reasons in the Codepen above.

The answer up until now is likely that folks need to implement their own ISelection interface which is non-trivial. Perhaps we can accommodate in current code or provide some guidance in documentation.

KevinTCoughlin avatar Jun 11 '19 21:06 KevinTCoughlin

@j-te in scenarios where the items in the array supplied to DetailsList can change (for example due to sorting), the getKey prop must be supplied. Here's a codepen with a working example: https://codepen.io/krajeev/pen/RzNoLO I only made two small changes to our existing sample code: First, In _generateDocuments I am assigning a key to each document. The document's key does not change even when the items array is sorted. Second, I am also supplying getKey prop to DetailsList. We will be updating our sample code and documentation to reflect this.

Rajeev-K avatar Jun 11 '19 23:06 Rajeev-K

Awesome debugging @Rajeev-K! Looking forward to the fix.

KevinTCoughlin avatar Jun 11 '19 23:06 KevinTCoughlin

:tada:This issue was addressed in #9428, which has now been successfully released as [email protected].:tada:

Handy links:

msft-github-bot avatar Jun 14 '19 12:06 msft-github-bot