Skip to content

csv_preview: Implement data_table columns pining#56619

Merged
smitbarmase merged 12 commits into
zed-industries:mainfrom
HalavicH:feat/data-table/implement-column-pinning
May 15, 2026
Merged

csv_preview: Implement data_table columns pining#56619
smitbarmase merged 12 commits into
zed-industries:mainfrom
HalavicH:feat/data-table/implement-column-pinning

Conversation

@HalavicH

@HalavicH HalavicH commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds column pinning (freeze) capability to data tables, allowing the first N columns to remain visible while scrolling horizontally through the rest of the table content.

Common spreadsheet/data table UX pattern. When viewing wide tables with many columns, users need to see identifying information (row labels, IDs) while scrolling right to explore data.

Demo

Idle state:
image
Scrolled horizontally (name column dissapeared, line numbers column stayed pinned):
image

Implementation

  • New pin_cols(n: usize) builder method on Table to specify how many columns to pin
  • Pinned columns render in a fixed section that doesn't scroll horizontally
  • Scrollable columns render separately with independent scroll state
  • Horizontal scroll offset adjustments for proper column resize handle positioning with pinned sections
  • Pinned section stays at viewport left edge while scrollable section scrolls independently
  • Supports 0 < pinned_cols < total_cols (partial pinning)
  • Applied to CSV preview for better UX with wide datasets

Context

Part of CSV preview feature series, following PR #53496 (settings UI).

Before you mark this PR as ready for review, make sure that you have:

  • Added a solid test coverage and/or screenshots from doing manual testing
  • Done a self-review taking into account security and performance aspects
  • Aligned any UI changes with the UI checklist no ui changes besides pinning itself. UI improvements out of scope of this PR

Release Notes:

  • Improved CSV preview with column pinning to keep identifiers visible while scrolling

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 13, 2026
@HalavicH HalavicH marked this pull request as ready for review May 13, 2026 09:58
@smitbarmase smitbarmase self-assigned this May 13, 2026
@Anthony-Eid

Copy link
Copy Markdown
Contributor

I think for a feature like this it's important to have tests asserting the behavior we want

cc: @smitbarmase

@smitbarmase smitbarmase left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, I found a few nits, but there is one panic here that we should address first.

Comment thread crates/csv_preview/src/renderer/render_table.rs
Comment thread crates/ui/src/components/data_table.rs Outdated
Comment thread crates/csv_preview/src/renderer/render_table.rs
Comment thread crates/ui/src/components/data_table.rs Outdated
HalavicH and others added 8 commits May 14, 2026 11:30
- Fix panic: clamp pinned_cols to valid range before slicing widths
- Remove 4 redundant clones in header rendering (clippy errors)
- Consolidate duplicate "disable if" cell-styling logic with render_cell() helper
- Move pinned_width/total_scrollable_width computation into render_resize_handles_resizable()

@smitbarmase smitbarmase left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, I refactored the code a bit and added a few basic tests. I think this is much cleaner now.

@smitbarmase smitbarmase enabled auto-merge May 15, 2026 07:58
@smitbarmase smitbarmase added this pull request to the merge queue May 15, 2026
Merged via the queue into zed-industries:main with commit dca5976 May 15, 2026
49 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants