Reordering hidden columns#74
Conversation
As described in universal-ember#152, the behaviour when reordering over hidden columns is incorrect. This test illustrates the expected behaviour so that we can fix the implementation.
To make it easier to play with show/hiding then moving columns
In order to make the previously added test pass we need to give the column reordering plugin access to _all_ columns, not just the visible ones. When moving left or right we need to iteratively swap the position of adjacent columns, continuing until we have swapped with a visible column. There are some failing tests for internals of the component on this commit but they can be fixed up later. I want to see if the new UX is desirable.
By adding any missing columns to the end of the list whenever the data is passed _in_ we will be able to simplify any logic around reordering because it will know that it is dealing with a full set of columns
This is the next piece of guaranteeing that we are dealing with a full set of positions within the addon code. By verifying on input we can save ourselves verifying on every calculation / output.
It turns out that we can't test this functionality because we're hitting some asserts in other functionality which should now be considered unnecessary so we'll have to do some other cleaning up before this test can go green.
So that we don't need to worry about checking for and filling consecutive slots throughout the code
As described in universal-ember#152, the behaviour when reordering over hidden columns is incorrect. This test illustrates the expected behaviour so that we can fix the implementation.
To make it easier to play with show/hiding then moving columns
In order to make the previously added test pass we need to give the column reordering plugin access to _all_ columns, not just the visible ones. When moving left or right we need to iteratively swap the position of adjacent columns, continuing until we have swapped with a visible column. There are some failing tests for internals of the component on this commit but they can be fixed up later. I want to see if the new UX is desirable.
By adding any missing columns to the end of the list whenever the data is passed _in_ we will be able to simplify any logic around reordering because it will know that it is dealing with a full set of columns
This is the next piece of guaranteeing that we are dealing with a full set of positions within the addon code. By verifying on input we can save ourselves verifying on every calculation / output.
It turns out that we can't test this functionality because we're hitting some asserts in other functionality which should now be considered unnecessary so we'll have to do some other cleaning up before this test can go green.
So that we don't need to worry about checking for and filling consecutive slots throughout the code
…trike/ember-headless-table into reordering-hidden-columns * 'reordering-hidden-columns' of https://github.com/CrowdStrike/ember-headless-table: chore: Ensure consecutive zero based positions when initialised test: Add a test trying to hit `removeExtraColumnsFromMap` fix: Remove any extra columns from the passed in map feat: Explicitly add any missing columns to the end of the list chore: Fix column ordering demo feat: Implement more intuitive column sorting demo: Add an extra column to the demo test: Update test because we can and should retain the position of hidden elements test: Add a failing test showing the reorder problem # Conflicts: # docs/demo/demo-a.md # docs/demos/external-column-ordering/demo/demo-a.md # table/src/plugins/column-reordering/plugin.ts # test-app/tests/plugins/column-reordering/orderOf-test.ts # test-app/tests/plugins/column-reordering/rendering-test.gts
|
how'd you pull over the git history? that's cool 🎉 |
|
Labeling as breaking, since the API for ColumnOrder is changing |
|
@NullVoxPopuli Yes, I guess i fetched from that remote branch, and since it was "similar enough", it kind of worked. Don't ask me to do it again:p Yet, I'm using this as a patch now, but would be great to get it in. I guess it can be considered a bugfix with changed API. |
|
oh is still WIP? I haven't reviewed cause i thought it was still being worked on |
* main: (21 commits) Prepare Release using 'release-plan' remove unused @ts-expect-error pass through generics of resize handle consistency make sure generics are passed into helpers Update pnpm to v10.14.0 (universal-ember#90) Update Node.js to v22.18.0 (universal-ember#89) Update dependency @babel/runtime to v7.28.2 (universal-ember#91) Update dependency @embroider/addon-shim to v1.10.0 (universal-ember#76) Update dependency @babel/runtime to v7.27.6 (universal-ember#85) Update dependency ember-resources to v7.0.6 (universal-ember#81) Update dependency ember-modify-based-class-resource to v1.1.2 (universal-ember#83) Update dependency ember-modifier to v4.2.2 (universal-ember#82) Update pnpm to v10.12.1 (universal-ember#86) Update Node.js to v22.16.0 (universal-ember#79) Update pnpm to v10.11.0 (universal-ember#70) Update dependency @babel/runtime to v7.27.1 (universal-ember#78) Update dependency reactiveweb to v1.4.1 (universal-ember#77) Update dependency vite to v6.2.7 [SECURITY] (universal-ember#80) Update dependency @babel/runtime to v7.27.0 (universal-ember#69) ...
|
Ah, sure, np. I just tested this properly now, and think this is ready for review 🙏. Be ware: What is not working well (sometimes) is saving preferences to localstore/etc when using localhost. That is not related to this PR though, see CrowdStrike/ember-headless-table#239 and CrowdStrike/ember-headless-table#237 |
* main: Prepare Release using 'release-plan' lint:fix 'fix' for dumb ts fix types lint:fix add set widths to docs app example of table-layout: fixed adding table setting Fixed table layout for simpler calculations in fixed-table layouts
| this.pendingColumnOrder = new ColumnOrder({ | ||
| columns: () => this.columns, | ||
| allColumns: () => this.columns, | ||
| availableColumns: () => this.columns.reduce(function(acc, col) { |
There was a problem hiding this comment.
sorry it's taken me so long to get to this PR. <3
can you add a comment in this demo's code (maybe inline) about why ColumnOrder takes two separate collections of the columns?
| ); | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
can we bring this comment back? <#
…ts. Graceful handling of column mismatches. When localStorage contains a column order from a previous deployment with different columns, the function now normalizes the map by adding missing columns and removing extra ones instead of throwing an error.
// DON'T remove extra columns - they might be hidden columns, not deleted ones
|
@NullVoxPopuli Thanks, I have now addressed your comments. I have managed to find a way to make so this may not be a required to be a breaking change anymore if we revert to calling it 'columns', but i guess |
…umns to visibleColumns to align better with naming elsewhere in @universal-ember/table
|
@NullVoxPopuli I added a commit now in the attempt to make this a non-breaking change. |
See CrowdStrike/ember-headless-table#185 for reference