Skip to content

Conversation

@ling1726
Copy link
Contributor

@ling1726 ling1726 commented Nov 28, 2022

⚠️ Breaking change

In order to avoid future naming conflicts hooks have been renamed to be more specific to the Table component

  • useSelection -> useTableSelection
  • useSort -> useTableSort
  • useTable -> useTableFeatures (to avoid conflict with useTable_unstable)

Previous Behavior

  import { useTable, useSort, useSelection } from '@fluentui/react-components/unstable';
  const {
    getRows,
    selection: { allRowsSelected, someRowsSelected, toggleAllRows, toggleRow, isRowSelected },
    sort: { getSortDirection, toggleColumnSort, sort },
  } = useTable(
    {
      columns,
      items,
    },
    [
      useSelection({
        selectionMode: 'multiselect',
        defaultSelectedItems: new Set([0, 1]),
      }),
      useSort({ defaultSortState: { sortColumn: 'file', sortDirection: 'ascending' } }),
    ],
  );

New Behavior

  import { useTableFeatures, useTableSort, useTableSelection } from '@fluentui/react-components/unstable';
  const {
    getRows,
    selection: { allRowsSelected, someRowsSelected, toggleAllRows, toggleRow, isRowSelected },
    sort: { getSortDirection, toggleColumnSort, sort },
  } = useTableFeatures(
    {
      columns,
      items,
    },
    [
      useTableSelection ({
        selectionMode: 'multiselect',
        defaultSelectedItems: new Set([0, 1]),
      }),
      useTableSort({ defaultSortState: { sortColumn: 'file', sortDirection: 'ascending' } }),
    ],
  );

In order to avoid future conflict with the component hook
`useTable_unstable`. The headless state `useTable` hook has been renamed
to `useTableFeatures`.
@size-auditor
Copy link

size-auditor bot commented Nov 28, 2022

Asset size changes

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

Baseline commit: 6f450a1713c40d5429306ab1f6d76bc19e65c295 (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 28, 2022

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1294 1352 5000
Button mount 932 936 5000
FluentProvider mount 1608 1596 5000
FluentProviderWithTheme mount 627 629 10
FluentProviderWithTheme virtual-rerender 582 589 10
FluentProviderWithTheme virtual-rerender-with-unmount 640 627 10
MakeStyles mount 1890 1923 50000
SpinButton mount 2526 2529 5000

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 28, 2022

📊 Bundle size report

Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
59.018 kB
16.371 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
186.456 kB
52.327 kB
react-components
react-components: FluentProvider & webLightTheme
33.48 kB
11.037 kB
react-portal-compat
PortalCompatProvider
5.857 kB
1.978 kB
🤖 This report was generated against 6f450a1713c40d5429306ab1f6d76bc19e65c295

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 28, 2022

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 4775f03:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@fabricteam
Copy link
Collaborator

fabricteam commented Nov 28, 2022

🕵 fluentuiv9 No visual regressions between this PR and main

@layershifter
Copy link
Member

Is there sense to also rename useSelection & useSort? import { useSort } from '@fluentui/react-components' might be confusing as it does not have a connection to the component.

@ling1726
Copy link
Contributor Author

Is there sense to also rename useSelection & useSort? import { useSort } from '@fluentui/react-components' might be confusing as it does not have a connection to the component.

Perhaps, there's less urgency there since there's no naming conflict there

@ling1726
Copy link
Contributor Author

In any case I've renmaed useSelection and useSort to useTableSelection and useTableSort respectively @layershifter

@ling1726 ling1726 enabled auto-merge (squash) November 30, 2022 15:18
@ling1726 ling1726 closed this Dec 1, 2022
auto-merge was automatically disabled December 1, 2022 09:26

Pull request was closed

@ling1726 ling1726 reopened this Dec 1, 2022
@ling1726 ling1726 merged commit 8811bf9 into microsoft:master Dec 1, 2022
marcosmoura added a commit to marcosmoura/fluentui that referenced this pull request Dec 1, 2022
* master:
  BREAKING: `useTable` renamed to `useTableFeatures` (microsoft#25797)
  chore: add retries for navigation in ssr-tests-v9 (microsoft#25844)
  fix: Cell actions should have correct background when row focused within (microsoft#25790)
  applying package updates
  Disable 3 Avatar Converged active stories (microsoft#25765)
  chore: introduce TS path aliases for improved DX in v8 (microsoft#25778)
  chore: prepare release react-northstar 0.65.0 (microsoft#25446)
  refactor(scripts): encapsulate v0 and v8 tooling within its domain boundaries (microsoft#25738)
  Support single point in area chart (microsoft#25842)
  chore: enable isolateModules in all v8 packages (microsoft#25774)
  chore: refactor styles for Button (microsoft#25216)
  feat: Improve docs for `DataGrid`, export as unstable (microsoft#25805)
  applying package updates
  fix: Allow data-selection-disabled to be respected by DetailsRow (microsoft#25836)
  docs(rfcs): Update recipes rfc with chosen option and add more details (microsoft#25823)
  chore(react-textarea): migrate to new package structure (microsoft#25820)
  chore(react-switch): migrate to new package structure (microsoft#25819)
  fix(react-avatar): AvatarGroup's pie layout places inline items correctly in rtl (microsoft#25822)
  chore: add few improvements to toolbar stories (microsoft#25635)
Hotell pushed a commit to Hotell/fluentui that referenced this pull request Feb 9, 2023
* BREAKING: `useTable` renamed to `useTableFeatures`

In order to avoid future conflict with the component hook
`useTable_unstable`. The headless state `useTable` hook has been renamed
to `useTableFeatures`.

* changefiles

* rename `useSelection` and `useSort` hooks

* update changefiles
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.

4 participants