Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allSelectedRows and someSelectedRows should be more reliable #28577

Merged

Conversation

ling1726
Copy link
Member

We took the decision to decouple the selection state from the data. This means that the selection state does not always stay in sync with the data, but the resulting output should be correct.

In this case allSeletedRows and someSelectedRows were calculated based on the size of the selected rows which was wrong, because there can be outdated values in there. Updates the useTableSelection hook to make sure that those states reflect the what is in the data. This will cause extra computation (which is memoized) but there is no other way to maintain consistency.

It might be possible to update useSelection accept the set of selectable items, but the extra computation will still need to be there.

Fixes #28456

We took the decision to decouple the selection state from the data. This
means that the selection state does not always stay in sync with the
data, but the resulting output should be correct.

In this case `allSeletedRows` and `someSelectedRows` were calculated
based on the size of the selected rows which was wrong, because there
can be outdated values in there. Updates the `useTableSelection` hook
to make sure that those states reflect the what is in the data. This
will cause extra computation (which is memoized) but there is no other
way to maintain consistency.

It might be possible to update `useSelection` accept the set of
selectable items, but the extra computation will still need to be there.

Fixes microsoft#28456
@github-actions github-actions bot added this to the July Project Cycle Q3 2023 milestone Jul 19, 2023
@ling1726 ling1726 marked this pull request as ready for review July 19, 2023 13:00
@ling1726 ling1726 requested a review from a team as a code owner July 19, 2023 13:00
@fabricteam
Copy link
Collaborator

fabricteam commented Jul 19, 2023

Perf Analysis (@fluentui/react-components)

Scenario Render type Master Ticks PR Ticks Iterations Status
FluentProviderWithTheme virtual-rerender 70 69 10 Possible regression
All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 607 582 5000
Button mount 297 294 5000
Field mount 1037 1051 5000
FluentProvider mount 654 630 5000
FluentProviderWithTheme mount 67 81 10
FluentProviderWithTheme virtual-rerender 70 69 10 Possible regression
FluentProviderWithTheme virtual-rerender-with-unmount 67 86 10
InfoButton mount 11 11 5000
MakeStyles mount 845 858 50000
Persona mount 1667 1621 5000
SpinButton mount 1286 1340 5000

@fabricteam
Copy link
Collaborator

fabricteam commented Jul 19, 2023

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-table
DataGrid
158.282 kB
43.276 kB
158.648 kB
43.391 kB
366 B
115 B
react-table
Table as DataGrid
132.365 kB
33.849 kB
132.734 kB
33.992 kB
369 B
143 B
react-table
Table (Selection only)
77.993 kB
19.245 kB
78.359 kB
19.372 kB
366 B
127 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
67.576 kB
18.225 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
213.085 kB
59.114 kB
react-components
react-components: FluentProvider & webLightTheme
36.409 kB
12.003 kB
react-portal-compat
PortalCompatProvider
6.48 kB
2.203 kB
react-table
Table (Primitives only)
44.666 kB
12.442 kB
react-table
Table (Sort only)
76.978 kB
18.973 kB
🤖 This report was generated against 5a4b16715e8e929f11d8113f710e578ca73acaa6

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 19, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 6da7bb1:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration
elastic-galileo-s2gt42 Issue #28456
suspicious-lehmann-4v9rc2 Issue #28456

@fabricteam
Copy link
Collaborator

fabricteam commented Jul 19, 2023

🕵 fluentuiv9 No visual regressions between this PR and main

@size-auditor
Copy link

size-auditor bot commented Jul 19, 2023

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: 5a4b16715e8e929f11d8113f710e578ca73acaa6 (build)

@ling1726 ling1726 merged commit 038d8f7 into microsoft:master Jul 21, 2023
21 checks passed
marcosmoura added a commit to marcosmoura/fluentui that referenced this pull request Jul 25, 2023
* master: (32 commits)
  chore: remove @fluentui/bundle-size (microsoft#28601)
  Breadcrumb UI adjustments (microsoft#28578)
  feat(tools): re-generate react-components.api.md when preparing 1st stable release (microsoft#28561)
  perf(tools): make dependency-mismatch execution 90% faster and ignore */>=9.0.0-alpha versions (microsoft#28597)
  Table/DataGrid: keyboard resizing improvements (microsoft#28493)
  docs(react-tooltip): Add info icon + tooltip story to Tooltip stories (microsoft#28611)
  chore: Updating @fluentui/react-icons to version 2.0.207 (microsoft#28590)
  feat: allSelectedRows and someSelectedRows should be more reliable (microsoft#28577)
  add vr test to react-tags (microsoft#28484)
  applying package updates
  chore: migrate to monosize (microsoft#26826)
  fix(react-conformance): add @swc/helpers to deps instead of tslib as we use swc for transpilation (microsoft#28599)
  fix: MenuItem content should be spaced 12px from the boundary (microsoft#28162)
  feat: implements selection (microsoft#28497)
  bugfix: moves handleBackdropClick from defaultProps to an override (microsoft#28579)
  Fix empty CSS creation (microsoft#28566)
  chore: replace plop with nx within create-* aliases in root package.json (microsoft#28575)
  applying package updates
  fix: High contrast mode hover style icon fixes in react-button components (microsoft#28156)
  SplitButton: updated border right token for primary variant (microsoft#28555)
  ...
@mhverbakel
Copy link
Contributor

@ling1726 The algorithm for allRowsSelected returns true when there are no rows. While technically correct (logic and set theory dictates that for all on an empty set returns true), this gives the counter-intuitive case where an empty data grid/table has the checkbox for selecting all rows checked.

Is this a deliberate choice? Or is this something that was overlooked?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Table multi-selection always selects the next item by default when an item above it is been removed
4 participants