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(cdk/table): fixed table layouts #20258
feat(cdk/table): fixed table layouts #20258
Conversation
0afa05e
to
ef2ead2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to account for changes in the table's width and invalidating the cell widths. E.g. if the table's width depends on the screen width, and the window is resized, the cell widths should be invalidated.
70f048e
to
82302c5
Compare
@andrewseguin Ready for another review. |
82302c5
to
1dc118f
Compare
src/cdk/table/table.ts
Outdated
protected readonly _viewRepeater: _ViewRepeater<T, RenderRow<T>, RowContext<T>>) { | ||
protected readonly _viewRepeater: _ViewRepeater<T, RenderRow<T>, RowContext<T>>, | ||
// Optional for backwards compatibility, but a view ruler will always be provided. | ||
private readonly _viewportRuler: ViewportRuler) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding non-optional constructor params here would be a breaking change since we expect that people extend CdkTable
. Can we make this work with these new params being @Optional
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -188,8 +189,10 @@ export interface RenderRow<T> { | |||
selector: 'cdk-table, table[cdk-table]', | |||
exportAs: 'cdkTable', | |||
template: CDK_TABLE_TEMPLATE, | |||
styleUrls: ['table.css'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these styles get included when using mat-table
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the PR to include styles for both the material table and MDC table.
return this._fixedLayout; | ||
} | ||
set fixedLayout(v: boolean) { | ||
this._fixedLayout = coerceBooleanProperty(v); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be an extremely uncommon edge case, but would it be correct to reset any values here depending on whether the table is being set one way or the other? E.g. when this changes, should _forceRecalculateCellWidths
be set to true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. Yes, both _forceRecalculateCellWidths
and _stickyColumnStylesNeedReset
should be set to true.
Done
src/cdk/table/table.ts
Outdated
|
||
// Table cell dimensions may change after resizing the window. Signal the sticky styler to | ||
// refresh its cache of cell widths the next time sticky styles are updated. | ||
this._viewportRuler.change().subscribe(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, any subscribe
should be matched with a corresponding unsubscribe
somewhere else, otherwise it'll get stuck in memory.
You can use this pipe to handle it: .pipe(takeUntil(this._onDestroy))
, just like we do with the dataStream in _observeRenderChanges
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
9d80892
to
6ab9fb1
Compare
6ab9fb1
to
93225b4
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Summary
fixedColumnWidths
input to the CDK table. Whentrue
, native tables will display withtable-layout: fixed
. No-op for flex tables.Open question
fixedLayout
might make a better name for the input. Preferences?