feat: noNativeElements renders table with flex layout#24913
Merged
ling1726 merged 6 commits intomicrosoft:masterfrom Sep 29, 2022
Merged
feat: noNativeElements renders table with flex layout#24913ling1726 merged 6 commits intomicrosoft:masterfrom
noNativeElements renders table with flex layout#24913ling1726 merged 6 commits intomicrosoft:masterfrom
Conversation
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.
Collaborator
📊 Bundle size report
Unchanged fixtures
|
|
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:
|
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 3b48ff5d92433635997aa69a59b138ec273172ea (build) |
Collaborator
Perf Analysis (
|
| 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 |
layoutType prop to Table with flex optionnoNativeElements renders table with flex layout
Comment on lines
+41
to
+44
| const layoutStyles = { | ||
| table: useTableLayoutStyles(), | ||
| flex: useFlexLayoutStyles(), | ||
| }; |
Member
There was a problem hiding this comment.
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'), | ||
| }, | ||
| }); |
Member
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Native
display: tableis 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,
noNativeElementsnow 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:
tableelements are the most accessibledisplay: tableis simply faster at rendering tables thandisplay; flexwe did benchmarks on this here.