-
Notifications
You must be signed in to change notification settings - Fork 5
Simple column resizing setting with tableLayout: 'fixed'
#97
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
Merged
NullVoxPopuli
merged 7 commits into
universal-ember:main
from
johanrd:simple-column-resizing-with-table-layout-fixed
Aug 25, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bff0fd4
adding table setting Fixed table layout for simpler calculations in f…
johanrd d68c980
add set widths to docs app example of table-layout: fixed
johanrd 106a7c4
lint:fix
johanrd a83358d
Merge branch 'main' into simple-column-resizing-with-table-layout-fixed
johanrd a266205
fix types
johanrd f07bd5c
'fix' for dumb ts
johanrd 3a5be20
lint:fix
johanrd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
101 changes: 101 additions & 0 deletions
101
test-app/tests/plugins/column-resizing/fixed-layout-test.gts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import Component from "@glimmer/component"; | ||
| import { tracked } from "@glimmer/tracking"; | ||
| import { htmlSafe } from "@ember/template"; | ||
| import { render } from "@ember/test-helpers"; | ||
| import { module, test } from "qunit"; | ||
| import { setupRenderingTest } from "ember-qunit"; | ||
| import { setOwner } from "@ember/owner"; | ||
|
|
||
| import { headlessTable, type ColumnConfig } from "@universal-ember/table"; | ||
| import { | ||
| ColumnResizing, | ||
| resizeHandle, | ||
| } from "@universal-ember/table/plugins/column-resizing"; | ||
| import { createHelpers } from "@universal-ember/table/test-support"; | ||
|
|
||
| import { TestStyles, getColumns, assertChanges, width } from "./utils.gts"; | ||
|
|
||
| module("Plugins | resizing | fixed layout", function (hooks) { | ||
| setupRenderingTest(hooks); | ||
|
|
||
| let ctx: Context; | ||
| let { dragLeft, dragRight } = createHelpers({ | ||
| resizeHandle: "[data-handle]", | ||
| }); | ||
|
|
||
| hooks.beforeEach(function () { | ||
| ctx = new Context(); | ||
| setOwner(ctx, this.owner); | ||
| }); | ||
|
|
||
| class Context { | ||
| @tracked containerWidth = 1000; | ||
|
|
||
| columns: ColumnConfig[] = [ | ||
| { | ||
| name: "A", | ||
| key: "A", | ||
| pluginOptions: [ColumnResizing.forColumn(() => ({ minWidth: 128 }))], | ||
| }, | ||
| { | ||
| name: "B", | ||
| key: "B", | ||
| pluginOptions: [ColumnResizing.forColumn(() => ({ minWidth: 128 }))], | ||
| }, | ||
| { | ||
| name: "C", | ||
| key: "C", | ||
| pluginOptions: [ColumnResizing.forColumn(() => ({ minWidth: 128 }))], | ||
| }, | ||
| { | ||
| name: "D", | ||
| key: "D", | ||
| pluginOptions: [ColumnResizing.forColumn(() => ({ minWidth: 128 }))], | ||
| }, | ||
| ]; | ||
|
|
||
| table = headlessTable(this, { | ||
| columns: () => this.columns, | ||
| data: () => [] as unknown[], | ||
| plugins: [ColumnResizing.with(() => ({ tableLayout: "fixed" }))], | ||
| }); | ||
| } | ||
|
|
||
| class FixedLayoutTestComponent extends Component<{ ctx: Context }> { | ||
| get table() { | ||
| return this.args.ctx.table; | ||
| } | ||
|
|
||
| get modifiers() { | ||
| return this.table.modifiers; | ||
| } | ||
|
|
||
| get testContainerStyle() { | ||
| return htmlSafe(`width: ${this.args.ctx.containerWidth}px`); | ||
| } | ||
|
|
||
| <template> | ||
| <TestStyles /> | ||
| <div data-container style={{this.testContainerStyle}}> | ||
| <div data-scroll-container {{this.modifiers.container}}> | ||
| <table style="table-layout: fixed;"> | ||
| <thead> | ||
| <tr> | ||
| {{#each this.table.columns as |column|}} | ||
| <th {{this.modifiers.columnHeader column}}> | ||
| <span>{{column.name}}</span> | ||
| <div | ||
| data-handle | ||
| {{resizeHandle column}} | ||
| type="button" | ||
| >|</div> | ||
| </th> | ||
| {{/each}} | ||
| </tr> | ||
| </thead> | ||
| </table> | ||
| </div> | ||
| </div> | ||
| </template> | ||
| } | ||
| }); |
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.
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'm not sure why Typescript can't retain the correct context here. I guess we have the same issue in
handlePositionand optionsFor etc.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.
yea, here:
you'd have to do
as const, which is annoying