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: noNativeElements renders table with flex layout #24913

Merged
merged 6 commits into from
Sep 29, 2022

Conversation

ling1726
Copy link
Member

@ling1726 ling1726 commented Sep 22, 2022

Native display: table is great for column alignment and simplifies column sizing. However, native table layout is not very virtualization friendly and does cannot handle any non-compliant element in the markup.

For virtualization and other cases that involve non-compliant table elements in markup, noNativeElements now renders the table also in a flex layout.

Flex layout is what was used before #24762 with fixes to column alignment for long content.

The recommended usage of table should be native semantic elements. This is because of:

  • Accessibility - native table elements are the most accessible
  • Performance - display: table is simply faster at rendering tables than display; flex we did benchmarks on this here.

Native `display: table` is great for column alignment and simplifies
column sizing. However, native table layout is not very virtualization
friendly and does cannot handle any non-compliant element in the markup.

For virtualization and other cases that involve non-compliant table
elements in markup, there is a `layoutType` prop with the `native`and
`flex` layouts.

Flex layout is what was used before microsoft#24762 with fixes to column
alignment for long content.
@fabricteam
Copy link
Collaborator

fabricteam commented Sep 22, 2022

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
189.188 kB
52.396 kB
189.156 kB
52.385 kB
-32 B
-11 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: FluentProvider & webLightTheme
33.4 kB
11.008 kB
react-portal-compat
PortalCompatProvider
5.857 kB
1.978 kB
🤖 This report was generated against ab22305f5de84554450ad0d1a5577fc7be753467

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 22, 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 ad8744d:

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

@size-auditor
Copy link

size-auditor bot commented Sep 22, 2022

Asset size changes

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

Baseline commit: 3b48ff5d92433635997aa69a59b138ec273172ea (build)

@fabricteam
Copy link
Collaborator

fabricteam commented Sep 22, 2022

Perf Analysis (@fluentui/react-components)

No significant results to display.

All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 1323 1356 5000
Button mount 966 940 5000
FluentProvider mount 1593 1600 5000
FluentProviderWithTheme mount 634 638 10
FluentProviderWithTheme virtual-rerender 596 589 10
FluentProviderWithTheme virtual-rerender-with-unmount 634 643 10
MakeStyles mount 1917 1875 50000
SpinButton mount 2551 2511 5000

@ling1726 ling1726 marked this pull request as ready for review September 27, 2022 15:10
@ling1726 ling1726 requested review from a team as code owners September 27, 2022 15:10
@ling1726 ling1726 changed the title feat: Adds layoutType prop to Table with flex option feat: noNativeElements renders table with flex layout Sep 27, 2022
Copy link
Contributor

@bsunderhus bsunderhus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ling1726 ling1726 closed this Sep 29, 2022
@ling1726 ling1726 reopened this Sep 29, 2022
@ling1726 ling1726 closed this Sep 29, 2022
@ling1726 ling1726 reopened this Sep 29, 2022
@ling1726 ling1726 merged commit 0bece74 into microsoft:master Sep 29, 2022
Comment on lines +41 to +44
const layoutStyles = {
table: useTableLayoutStyles(),
flex: useFlexLayoutStyles(),
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not sure that I understand the need to create an object there

Comment on lines +11 to +25
const useTableLayoutStyles = makeStyles({
root: {
display: 'table-cell',
verticalAlign: 'middle',
},
});

const useFlexLayoutStyles = makeStyles({
root: {
display: 'flex',
minWidth: '0px',
alignItems: 'center',
...shorthands.flex(1, 1, '0px'),
},
});
Copy link
Member

@layershifter layershifter Sep 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be just this ⬇️?

const useLayoutStyles = makeStyles({
  table: {
    display: 'table-cell',
    verticalAlign: 'middle',
  },
  flex: {
    display: 'flex',
    minWidth: '0px',
    alignItems: 'center',
    ...shorthands.flex(1, 1, '0px'),
  },
});

NotWoods pushed a commit to NotWoods/fluentui that referenced this pull request Nov 18, 2022
)

* feat: Adds `layoutType` prop to Table with flex option

Native `display: table` is great for column alignment and simplifies
column sizing. However, native table layout is not very virtualization
friendly and does cannot handle any non-compliant element in the markup.

For virtualization and other cases that involve non-compliant table
elements in markup, there is a `layoutType` prop with the `native`and
`flex` layouts.

Flex layout is what was used before microsoft#24762 with fixes to column
alignment for long content.

* update test and md

* vr tests should test both layout types

* changefiles

* noNativeElements decides layout

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

5 participants