You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
toggleAllRowsSelected fires onRowSelectionChange on a no-op, unlike toggleAllRowsExpanded after #6501 #6538
#6501 (closing #6136) added a no-op guard to table_toggleAllRowsExpanded so it stops calling onExpandedChange when the requested state already matches the current one. table_toggleAllRowsSelected has the identical shape of API (imperative toggle-all with an optional explicit boolean) and never got the same guard.
exportfunctiontable_toggleAllRowsSelected(table,value?,opts?){table._lastSelectedRowId=nulltable_setRowSelection(table,(old)=>{value=typeofvalue!=='undefined' ? value : !callMemoOrStaticFn(table,'getIsAllRowsSelected',table_getIsAllRowsSelected)if(opts?.deselectAll&&!value)returnmakeObjectMap<true>()constrowSelection=Object.assign(makeObjectMap<true>(),old)// ...builds the full selection map unconditionally...})}
No early return for the case where the resulting selection already matches old. table_setRowSelection itself is intentionally unguarded too (there's a comment explaining why: a full deep-equal over an arbitrary-sized selection map would be real overhead for genuine changes), but that rationale doesn't apply to toggleAllRowsSelected specifically, the O(1)-ish checks table_toggleAllRowsExpanded added (getIsAllRowsSelected() is already memoized, an empty-map check) are the same shape of cheap guard, not a full map comparison.
Repro
table.toggleAllRowsSelected(true)// selects everything, fires onRowSelectionChangetable.toggleAllRowsSelected(true)// everything is already selected...// onRowSelectionChange still fires, with a functionally identical resulting map
Same symptom #6136 described for expansion: a consumer syncing rowSelection to external state (URL, server) sees redundant writes on every no-op toggle, and any useEffect/watcher keyed on onRowSelectionChange re-runs for nothing.
Might be intentional given the differing rationale for the general setter, flagging with that caveat rather than assuming it's simply missed, but the parity with the just-fixed expansion API made it worth raising explicitly.
Activity