Skip to content

Conversation

@dg-ac
Copy link
Contributor

@dg-ac dg-ac commented Dec 6, 2025

This PR ensures that row heights automatically adapt when the font size changes.
Previously, increasing the font size could cause text to overflow or become clipped, requiring manual row resizing.
The update introduces a smarter height adjustment mechanism and fixes issues with multi-line cell content.


Changes

  1. Added a function to automatically adjust row height when font size increases.
  2. Added support for multi-line cells as well.
font.resizing.mov

Testing

  • Increase font size in a single cell and verify the row height adjusts automatically.
  • Test multi-line cells (Shift/Option+Enter) to ensure the entire content remains visible.
  • Apply font size changes to multiple selected rows and confirm consistent behavior.
  • Resize rows manually and check that automatic resizing still behaves correctly afterward.
  • Validate no regressions in row resizing across different browsers and screen sizes.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds automatic row height adjustment when font size changes in spreadsheet cells. Previously, increasing font size could cause text overflow, requiring manual row resizing. The implementation captures cell state before font size updates, calculates required heights based on the new font sizes and multi-line content, and applies the adjustments.

Key Changes

  • Added logic to automatically adjust row heights when font size increases or decreases
  • Implemented support for multi-line cells (created with Alt/Option+Enter) in height calculations
  • Added range normalization to handle selections made in any direction

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +192 to +193
const lineHeight = newFontSize * 1.5;
const requiredHeight = (maxLineCount - 1) * lineHeight + 8 + newFontSize;
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

The row height calculation doesn't consider the wrap_text style property. In worksheetCanvas.ts:1016-1021, the autofit logic uses computeWrappedLines() to properly calculate line count based on cell width and wrap settings. Without considering wrap_text, this implementation may calculate incorrect heights for cells with text wrapping enabled, potentially causing text to overflow or excess whitespace.

Copilot uses AI. Check for mistakes.
newRowHeight = DEFAULT_ROW_HEIGHT;
}

if (Math.abs(newRowHeight - oldRowHeight) > 0.1) {
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

The threshold 0.1 is a magic number without explanation. Consider extracting it as a named constant (e.g., MIN_HEIGHT_CHANGE_THRESHOLD = 0.1) with a comment explaining why this epsilon is needed (likely to avoid unnecessary updates for floating-point precision differences).

Copilot uses AI. Check for mistakes.
Comment on lines +195 to +200
let newRowHeight: number;
if (requiredHeight > DEFAULT_ROW_HEIGHT) {
newRowHeight = requiredHeight;
} else {
newRowHeight = DEFAULT_ROW_HEIGHT;
}
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

[nitpick] The variable newRowHeight is unnecessary since it's only assigned once and immediately used. Consider simplifying by directly assigning to a const:

const newRowHeight = requiredHeight > DEFAULT_ROW_HEIGHT ? requiredHeight : DEFAULT_ROW_HEIGHT;

This makes the code more concise and easier to read.

Suggested change
let newRowHeight: number;
if (requiredHeight > DEFAULT_ROW_HEIGHT) {
newRowHeight = requiredHeight;
} else {
newRowHeight = DEFAULT_ROW_HEIGHT;
}
const newRowHeight = requiredHeight > DEFAULT_ROW_HEIGHT ? requiredHeight : DEFAULT_ROW_HEIGHT;

Copilot uses AI. Check for mistakes.
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.

2 participants