File tree 2 files changed +9
-5
lines changed
packages/components/src/components/hds/table
showcase/app/controllers/components
2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -124,8 +124,9 @@ export default class HdsTable extends Component<HdsTableSignature> {
124
124
if ( this . args . identityKey === 'none' ) {
125
125
return undefined ;
126
126
} else {
127
- // We return a default key to cause an update operation instead of replacement when the model changes to side-step
128
- // a bug in Ember which would cause the table to lose its selection state
127
+ // We return `@identity` as default to cause an update operation instead of replacement when the model changes to avoid unexpected side effects
128
+ // see: "Specifying Keys" here: https://api.emberjs.com/ember/6.1/classes/Ember.Templates.helpers/methods/each?anchor=each
129
+ // see also: https://github.com/hashicorp/design-system/pull/1160 + https://github.com/hashicorp/cloud-ui/pull/5178 + https://hashicorp.atlassian.net/browse/HDS-4273
129
130
return this . args . identityKey ?? '@identity' ;
130
131
}
131
132
}
@@ -314,7 +315,7 @@ export default class HdsTable extends Component<HdsTableSignature> {
314
315
) ;
315
316
316
317
// Fix for selectableRows state not being maintained properly when model updates:
317
- // Delete the first row with the given selction key you find from the selectableRows array
318
+ // Delete the first row with the given selection key you find from the selectableRows array
318
319
// Search for the index of the row to delete. If found, delete it.
319
320
// (Fixes issue of not rows not being properly selectable including "select all" functionality)
320
321
const rowToDeleteIndex = this . _selectableRows . findIndex (
Original file line number Diff line number Diff line change @@ -28,8 +28,11 @@ export default class extends Controller {
28
28
@tracked lyrics = daysOfChristmas . slice ( ) ;
29
29
30
30
@action dirtyModel ( ) {
31
- // Deep copy to destroy references
32
- this . lyrics = this . lyrics . map ( ( r ) => ( { ...r } ) ) ;
31
+ this . lyrics = this . lyrics
32
+ // Deep copy to destroy references
33
+ . map ( ( r ) => ( { ...r } ) )
34
+ // Randomly sort to see what happens in this case
35
+ . sort ( ( ) => Math . random ( ) - 0.5 ) ;
33
36
}
34
37
35
38
printSelection = ( selection ) =>
You can’t perform that action at this time.
0 commit comments