Skip to content

Fix column layout shift when inline editing (issue #2244)#2247

Merged
ideav merged 3 commits intomainfrom
issue-2244-2d06b6184c17
Apr 29, 2026
Merged

Fix column layout shift when inline editing (issue #2244)#2247
ideav merged 3 commits intomainfrom
issue-2244-2d06b6184c17

Conversation

@konard
Copy link
Copy Markdown
Collaborator

@konard konard commented Apr 29, 2026

Problem

Despite PR #2241 fixing the row-height shift, the column widths still shift when editing a cell inline. The "Формула" column disappears and adjacent columns become wider while an editor is active (see issue screenshots).

Root Cause

PR #2241 removed the padding override that caused row-height growth, but the underlying cause of column reflow was not addressed:

  • The table uses table-layout: auto (browser default), so column widths are determined by content
  • When an <input> or <textarea> is inserted into a cell, the browser recalculates all column widths based on the new content
  • HTML input elements have an intrinsic minimum size that can push columns wider, overriding the auto-computed widths from before editing

Fix

JS (js/integram-table/07-inline-edit.js):

  • _freezeColumnWidths(): called just before the inline editor is inserted. Reads the current rendered offsetWidth of each th and locks it via inline style.width / style.minWidth. Only freezes headers that don't already have a manually-saved width in this.columnWidths, so user-resized columns are unaffected.
  • _unfreezeColumnWidths(): called when editing ends (save, cancel, or new-row cancel). Removes the temporary inline styles so the table returns to auto-layout.
  • Called from startInlineEdit, startNewRowFirstColumnEdit, saveInlineEdit, cancelInlineEdit, saveNewRowFirstColumn, and cancelNewRow.

CSS (css/integram-table.css):

  • Added min-width: 0 to .inline-editor as a CSS-level guard against the input's intrinsic size expanding the column width.

How to reproduce

  1. Open a table with multiple columns (e.g. Панель Операционные показатели: Строка)
  2. Note the column widths before editing
  3. Click a cell to edit it — columns should no longer shift

Testing

The freeze/unfreeze cycle is symmetric: every edit path (regular save, cancel, Tab navigation, new row) now correctly unfreezes on exit.

Fixes #2244

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #2244
@konard konard self-assigned this Apr 29, 2026
PR #2241 fixed row-height shift by removing padding override, but the
column widths still shifted because the table uses table-layout: auto —
inserting an input element into a cell lets the browser re-distribute
column widths based on the new content.

Fix: snapshot each th's rendered offsetWidth and lock it as an inline
style just before the inline editor is inserted (_freezeColumnWidths),
then remove those temporary styles once editing ends (_unfreezeColumnWidths).
Only headers without a manually-saved width are frozen, so user-resized
columns are unaffected.

Also add min-width: 0 to .inline-editor so the input's intrinsic size
cannot push the column wider as a CSS-level guard.

Fixes #2244
@konard konard changed the title [WIP] https://github.com/ideav/crm/pull/2241 все равно разъезжается при редактировании Fix column layout shift when inline editing (issue #2244) Apr 29, 2026
@konard konard marked this pull request as ready for review April 29, 2026 11:48
@konard
Copy link
Copy Markdown
Collaborator Author

konard commented Apr 29, 2026

Solution summary

The fix is implemented and pushed. Here's a summary of what was done:

Summary

Root cause: PR #2241 fixed row-height shift by removing padding overrides, but column widths still shifted because the table uses table-layout: auto. When an <input> element replaces cell content, the browser recalculates all column widths — pushing some columns wider and causing others (like "Формула") to be pushed out of view.

Fix — two-part:

  1. JS (js/integram-table/07-inline-edit.js): Added _freezeColumnWidths() that snapshots each column header's current rendered pixel width and locks it as an inline style just before the editor is inserted. Added _unfreezeColumnWidths() that removes those temporary styles when editing ends. Called symmetrically from all edit start/end paths.

  2. CSS (css/integram-table.css): Added min-width: 0 to .inline-editor so the input's intrinsic minimum size can't expand column widths as a secondary guard.

PR: #2247


This summary was automatically extracted from the AI working session output.

@konard
Copy link
Copy Markdown
Collaborator Author

konard commented Apr 29, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $1.753013

📊 Context and tokens usage:

  • 76.3K / 1M (8%) input tokens, 17.9K / 64K (28%) output tokens

Total: (70.3K + 4.1M cached) input tokens, 17.9K output tokens, $1.753013 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Model: Claude Sonnet 4.6 (claude-sonnet-4-6)

📎 Log file uploaded as Gist (3406KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Collaborator Author

konard commented Apr 29, 2026

✅ Ready to merge

This pull request is now ready to be merged:

  • No CI/CD checks are configured for this repository
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@ideav ideav merged commit bce653c into main Apr 29, 2026
@ideav ideav deleted the issue-2244-2d06b6184c17 branch April 29, 2026 14:15
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.

https://github.com/ideav/crm/pull/2241 все равно разъезжается при редактировании

2 participants