Skip to content

Reordering hidden columns#74

Merged
NullVoxPopuli merged 32 commits into
universal-ember:mainfrom
johanrd:reordering-hidden-columns
Oct 3, 2025
Merged

Reordering hidden columns#74
NullVoxPopuli merged 32 commits into
universal-ember:mainfrom
johanrd:reordering-hidden-columns

Conversation

@johanrd
Copy link
Copy Markdown
Contributor

@johanrd johanrd commented Apr 11, 2025

vitch and others added 21 commits July 4, 2023 10:41
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
@NullVoxPopuli
Copy link
Copy Markdown
Contributor

how'd you pull over the git history? that's cool 🎉

@NullVoxPopuli
Copy link
Copy Markdown
Contributor

Labeling as breaking, since the API for ColumnOrder is changing

@johanrd
Copy link
Copy Markdown
Contributor Author

johanrd commented Aug 25, 2025

@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.

@johanrd johanrd marked this pull request as ready for review August 25, 2025 14:23
@NullVoxPopuli
Copy link
Copy Markdown
Contributor

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)
  ...
@johanrd johanrd changed the title [WIP] Reordering hidden columns Reordering hidden columns Aug 25, 2025
@johanrd
Copy link
Copy Markdown
Contributor Author

johanrd commented Aug 25, 2025

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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?

);
}

/**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
@johanrd
Copy link
Copy Markdown
Contributor Author

johanrd commented Oct 3, 2025

@NullVoxPopuli Thanks, I have now addressed your comments. I have managed to find a way to make availableColumns optional in the ColumnOrder args (while making the removal/add columns from storage more resilient).

so this may not be a required to be a breaking change anymore if we revert to calling it 'columns', but i guess allColumns is more descriptive?

…umns to visibleColumns to align better with naming elsewhere in @universal-ember/table
@johanrd
Copy link
Copy Markdown
Contributor Author

johanrd commented Oct 3, 2025

@NullVoxPopuli I added a commit now in the attempt to make this a non-breaking change.

@NullVoxPopuli NullVoxPopuli added enhancement New feature or request bug Something isn't working and removed breaking labels Oct 3, 2025
@NullVoxPopuli NullVoxPopuli merged commit affb79c into universal-ember:main Oct 3, 2025
13 of 18 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants