Skip to content

Prevent table columns to be too narrow#16542

Merged
charlesBochet merged 2 commits intomainfrom
prevent-table-narrow
Dec 12, 2025
Merged

Prevent table columns to be too narrow#16542
charlesBochet merged 2 commits intomainfrom
prevent-table-narrow

Conversation

@charlesBochet
Copy link
Copy Markdown
Member

@charlesBochet charlesBochet commented Dec 12, 2025

😬
image

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Comment on lines +56 to +59
visibleRecordFields: visibleRecordFields.map((field) => ({
...field,
size: Math.max(field.size, RECORD_TABLE_COLUMN_MIN_WIDTH),
})),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The use of Math.max(field.size, ...) can result in NaN for column width calculations because field.size can be undefined at runtime, breaking the table layout.
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

The code calculates column width using Math.max(field.size, RECORD_TABLE_COLUMN_MIN_WIDTH). Although the type definition for field.size is number, evidence from other parts of the codebase suggests it can be undefined at runtime. When field.size is undefined, Math.max returns NaN. This NaN value is then used in column width calculations, which will break the table layout and rendering. This is a silent failure that can be difficult to debug.

💡 Suggested Fix

Provide a default value for field.size before passing it to Math.max to handle cases where it might be undefined. For example, use the nullish coalescing operator: Math.max(field.size ?? 0, RECORD_TABLE_COLUMN_MIN_WIDTH).

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location:
packages/twenty-front/src/modules/object-record/record-table/components/RecordTableContextProvider.tsx#L56-L59

Potential issue: The code calculates column width using `Math.max(field.size,
RECORD_TABLE_COLUMN_MIN_WIDTH)`. Although the type definition for `field.size` is
`number`, evidence from other parts of the codebase suggests it can be `undefined` at
runtime. When `field.size` is `undefined`, `Math.max` returns `NaN`. This `NaN` value is
then used in column width calculations, which will break the table layout and rendering.
This is a silent failure that can be difficult to debug.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 7459818

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@charlesBochet charlesBochet merged commit afcca28 into main Dec 12, 2025
61 checks passed
@charlesBochet charlesBochet deleted the prevent-table-narrow branch December 12, 2025 17:15
@twenty-eng-sync
Copy link
Copy Markdown

Hey @charlesBochet! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 12, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:62474

This environment will automatically shut down when the PR is closed or after 5 hours.

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