Skip to content

fix(tables): account for letter-spacing and displayed content in column auto-resize#4277

Merged
waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1/fix-table-autoresize
Apr 23, 2026
Merged

fix(tables): account for letter-spacing and displayed content in column auto-resize#4277
waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1/fix-table-autoresize

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Mount the auto-resize measurement span inside the table container so it inherits .workspace-root's letter-spacing: 0.02em — previously measured on document.body, leading to under-estimated widths and lingering ... on some rows
  • Switch from offsetWidth (rounds down) to getBoundingClientRect().width for fractional-pixel accuracy
  • Measure the displayed text per column type: JSON.stringify(val) for json, storageToDisplay(val) for date, skip boolean entirely

Type of Change

  • Bug fix

Testing

Tested manually — double-clicking column resize handle now fits content without ellipsis across text, json, and date columns.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 23, 2026 9:37pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 23, 2026

PR Summary

Low Risk
Low risk UI-only change that tweaks DOM measurement logic for column auto-resize; potential impact is limited to computed column widths and should be caught quickly in manual use.

Overview
Fixes table column auto-resize to better match what users actually see by measuring text within the table container (so inherited styles like letter-spacing apply) and using getBoundingClientRect().width for sub-pixel accuracy.

Auto-resize now formats values based on column type (stringified json, display-formatted date) and skips auto-resize for boolean columns.

Reviewed by Cursor Bugbot for commit 5c5b1c5. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 23, 2026

Greptile Summary

This PR fixes column auto-resize under-estimation by (1) mounting the hidden measurement span inside the table container so it inherits .workspace-root's letter-spacing: 0.02em, (2) switching from offsetWidth to getBoundingClientRect().width for sub-pixel accuracy, (3) skipping boolean columns, and (4) using the same display transformation per type (JSON.stringify for json, storageToDisplay for date) that the cell renderer uses. The changes are accurate and consistent with how values are displayed in cells (confirmed at lines 2775 and 2781).

Confidence Score: 5/5

Safe to merge — targeted bug fix with no risk of regressions.

No P0/P1 issues found. The measurement logic is consistent with the actual cell renderers (JSON.stringify for json at line 2775, storageToDisplay at line 2781). The overflow:hidden on the container does not affect getBoundingClientRect().width (layout-level API, not affected by paint clipping). All remaining observations are P2 quality notes.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table/table.tsx Fixes column auto-resize measurement by mounting the hidden span in the table container (to inherit letter-spacing), switching to getBoundingClientRect().width for sub-pixel accuracy, adding boolean column skip, and using type-correct display text (JSON.stringify for json, storageToDisplay for date).

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User double-clicks column resize handle] --> B[handleColumnAutoResize called]
    B --> C{column.type === 'boolean'?}
    C -- Yes --> D[Return early — checkboxes have fixed width]
    C -- No --> E[Get host: containerRef.current ?? document.body]
    E --> F[Create hidden span, append to host\ninherits letter-spacing from .workspace-root]
    F --> G[Measure column header width\ngetBoundingClientRect width + 57px]
    G --> H[For each row value]
    H --> I{column.type?}
    I -- json --> J[text = JSON.stringify val]
    I -- date --> K[text = storageToDisplay val]
    I -- other --> L[text = String val]
    J & K & L --> M[Measure text width\ngetBoundingClientRect width + 17px]
    M --> N[Track maxWidth]
    N --> O{More rows?}
    O -- Yes --> H
    O -- No --> P[newWidth = Math.min ceil maxWidth, 600]
    P --> Q[setColumnWidths + persist metadata]
    F -->|finally| R[host.removeChild measure span]
Loading

Reviews (1): Last reviewed commit: "fix(tables): account for letter-spacing ..." | Re-trigger Greptile

@waleedlatif1 waleedlatif1 merged commit 3b11c81 into staging Apr 23, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/fix-table-autoresize branch April 23, 2026 21:41
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.

1 participant