Skip to content

feat(ColumnManagement): Add sticky column ordering - #992

Open
logonoff wants to merge 2 commits into
patternfly:mainfrom
logonoff:gh-991
Open

logonoff wants to merge 2 commits into
patternfly:mainfrom
logonoff:gh-991

Conversation

@logonoff

@logonoff logonoff commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

closes #991

Assisted-by: Codex GPT-6 Luna

Screen.Recording.2026-10-07.at.10.36.11.AM.mp4

I tried to have the drag handle for the sticky column disabled as well, but Codex says that's not possible with the current react-drag-drop and instead it ended up reimplementing the entire package...

@dlabaj dlabaj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@gabipodolnikova gabipodolnikova left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the PR! It does what it should :)
But I left a few inline notes, the thing that is a bit of a problem is that the text in the doc is describing something that is not implemented.

### With drag and drop reordering

When `enableDragDrop` is set to `true`, users can drag and drop columns to reorder them. The order changes are reflected both in the modal and in the table when applied. This is useful when column order matters for the user experience.
When `enableDragDrop` is set to `true`, users can drag and drop columns to reorder them. The order changes are reflected both in the modal and in the table when applied. Select a column's **Sticky** checkbox to keep it at its current position; other columns cannot be moved into that position. The `isSticky` column property reflects this selection. In this example, the first `ID` column is sticky.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This states users can "Select a column's Sticky checkbox" — but no such checkbox is rendered anywhere. ListManager only renders the show/hide checkbox for each row.

As written, the docs page will describe an interaction that can't be performed. Either the checkbox needs to be implemented, or this text should be updated to describe the prop-based behavior that actually exists (a consumer setting isSticky in the columns config).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch — there is no Sticky checkbox, so I rewrote this to describe the prop-based behavior that actually ships:

Set a column's isSticky property to true to pin it to its current position. A sticky column stays where it is and no other column can be moved into that position, while the remaining columns reorder around it. In this example, the ID column is sticky.

Fixed in 41f7cb6.

-- Claude Opus 5

/** Callback when a column is selected or deselected */
onSelect?: (column: ListManagerItem) => void;
/** Callback when a column's sticky state changes */
onStickyChange?: (column: ListManagerItem) => void;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

onStickyChange is declared here and passed by ColumnManagementModal (with a handleStickyChange handler), but ListManager never destructures it and has no code path that calls it — there's no UI that toggles isSticky.

As it stands this is dead code on both sides. Could it either be wired up to an actual control, or removed until that UI exists?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed, it was dead on both sides. Removed onStickyChange from ListManagerProps along with handleStickyChange and the prop pass in ColumnManagementModal.

While in there I also reverted the isSticky: matchingItem.isSticky ?? column.isSticky lines in updateColumns and handleOrderChange — the ...column / ...originalColumn spread already carries isSticky through, so those were no-ops too. The prop stays on ColumnManagementModalColumn and ListManagerItem, and handleSave still maps it explicitly since that one builds fresh objects.

Fixed in 41f7cb6.

-- Claude Opus 5

return found;
});

// Sticky columns reserve their current positions. Reorder only the remaining columns.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The sticky-position algorithm here (filter non-sticky columns, then re-slot them around the reserved positions) is non-trivial and currently has no test coverage — including edge cases like a sticky column in the middle of the list, all columns sticky, or a no-op drag.

Since this is the one piece of the feature that does ship, could tests be added for it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added a reordering describe block to ListManager.test.tsx covering the cases you named plus a couple more:

  • no column sticky (plain reorder)
  • leading sticky column
  • sticky column in the middle of the list
  • every column sticky
  • a drag that ends where it started
  • selection state surviving a reorder

Each case asserts both the onOrderChange payload and the rendered DOM order. The DragDropSort mock now records its props so a test can drop items in a specific order instead of only reversing them.

Added in 41f7cb6.

-- Claude Opus 5

Drop the onStickyChange callback from ListManagerProps and the
handleStickyChange handler in ColumnManagementModal. There is no control
that toggles isSticky, so nothing ever invoked the callback. Sticky state
comes from the columns config the consumer passes in, and the spread of
the existing column already carries it through updateColumns and
handleOrderChange, so the explicit isSticky reassignments there were
no-ops too.

The docs described selecting a "Sticky" checkbox, which does not exist.
Describe the prop-based behavior that actually ships instead.

Cover the sticky reorder algorithm in ListManager tests: leading sticky
column, sticky column in the middle, every column sticky, a drag that
ends where it started, and selection state surviving a reorder. The
DragDropSort mock now records its props so a test can drop items in a
specific order rather than only reversing them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ColumnManagementModal: add the ability to have sticky columns

3 participants