ember-headless-table icon indicating copy to clipboard operation
ember-headless-table copied to clipboard

Unexpected results when reordering with hidden columns

Open vitch opened this issue 2 years ago • 3 comments

As seen here:

hidden-columns

When "Column A" is re-shown I would expect it to still be at the start of the list.

From initial digging it seems like the reordering only happens on the visible columns and any non-visible columns are just appended to the end of the list. I think we need to keep invisible columns in the data structure that we are reordering

vitch avatar Apr 19 '23 09:04 vitch

oh no! It's certainly intended to behave the way you expect: https://github.com/CrowdStrike/ember-headless-table/blob/main/ember-headless-table/src/plugins/column-reordering/plugin.ts#L215

If you have time, there is an existing test you could use to make a reproduction of the behavior you've found: https://github.com/CrowdStrike/ember-headless-table/blob/main/test-app/tests/plugins/column-reordering/rendering-test.gts#L337 <3

NullVoxPopuli avatar Apr 19 '23 18:04 NullVoxPopuli

Planning to take a look at this tomorrow...

From an initial poke around it seems like we'll need to remove the coupling between the column-visibility and column-reordering plugins. Currently the reordering plugin receives the columns with visibility already applied so it won't be able to sensibly apply sorts. I think that the reordering plugin will have to run first - does that seem right?

vitch avatar May 16 '23 09:05 vitch

For this behavior/ requirement, the order can't be changed, i don't think: https://github.com/CrowdStrike/ember-headless-table/blob/main/ember-headless-table/src/plugins/column-reordering/plugin.ts#L217

This list, should probably maintain all columns (there's an api for that!)

https://github.com/CrowdStrike/ember-headless-table/blob/main/ember-headless-table/src/plugins/column-reordering/plugin.ts#L200

And then 'orderedColumns' can only return the visible columns.

This works well with the swap-only approach to reordering

NullVoxPopuli avatar May 16 '23 12:05 NullVoxPopuli