Fluentui: DetailsList selection not updating on items sort

Created on 11 Jun 2019  路  5Comments  路  Source: microsoft/fluentui

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)

Documentation DetailsList In PR

Most helpful comment

@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.

All 5 comments

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

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.

@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.

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

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

Handy links:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rickyp-ms picture rickyp-ms  路  3Comments

justinwilaby picture justinwilaby  路  3Comments

luisrudge picture luisrudge  路  3Comments

mattcoxonline picture mattcoxonline  路  3Comments

carruthe picture carruthe  路  3Comments