-
Notifications
You must be signed in to change notification settings - Fork 459
[DataGrid] Fix resize indicator height (when ResizeColumnOnAllRows is true) #4383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Unit Tests
Details on your Workflow / Core Tests page. |
There was a problem hiding this 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 fixes the height calculation for the resize indicator in the DataGrid component when ResizeColumnOnAllRows is set to true (issue #4378). The fix involves removing excessive padding from header cells and adjusting the positioning logic to properly align the resize handle.
Key changes:
- Removed CSS padding from column headers that was causing incorrect height calculations
- Adjusted min-height from 44px to 40px to compensate for the removed padding
- Updated resize handle positioning to be dynamically calculated based on the actual offset and DataGridDisplayMode
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| FluentDataGridCell.razor.css | Removed padding from .column-header class to fix height calculation |
| FluentDataGridCell.razor.cs | Reduced min-height from 44px to 40px to account for removed padding |
| FluentDataGrid.razor.js | Updated resize handle creation logic to dynamically calculate top position and adjusted height calculations |
| FluentDataGrid.razor.css | Removed hardcoded top: 5px from .resize-handle to allow dynamic positioning |
| FluentDataGrid.razor | Added dynamic top position calculation based on DataGridDisplayMode (4px for Table, 2px for Grid) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| resizedivs.forEach(div => div.remove()); | ||
|
|
||
| // Get the top of the first resize-handle | ||
| const resizeTop = header.querySelector('.resize-handle').offsetTop; |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code assumes .resize-handle will always exist when it calls offsetTop on the query result. If the resize-handle element is not found (e.g., if the DOM hasn't fully rendered), this will throw a null reference error. Consider adding a null check or providing a default value:
const resizeHandle = header.querySelector('.resize-handle');
const resizeTop = resizeHandle ? resizeHandle.offsetTop : 0;| const resizeTop = header.querySelector('.resize-handle').offsetTop; | |
| const resizeHandle = header.querySelector('.resize-handle'); | |
| const resizeTop = resizeHandle ? resizeHandle.offsetTop : 0; |
| // Only use the header height when resizeColumnOnAllRows is false | ||
| // Use the first header's height if available | ||
| resizeHandleHeight = headers.length > 0 ? (headers[0].offsetHeight - 14 ): 30; // fallback to 30px if no headers | ||
| resizeHandleHeight = headers.length > 0 ? (headers[0].offsetHeight - 14 ): 32; // fallback to 30px if no headers |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback value changed from 30px to 32px. While this might be intentional, there's no explanation in the code or comment for why this specific value was chosen. Consider adding a comment explaining the reasoning, especially since the height calculation at line 296 subtracts 4px, which relates to this value.
| resizeHandleHeight = headers.length > 0 ? (headers[0].offsetHeight - 14 ): 32; // fallback to 30px if no headers | |
| // Fallback value changed from 30px to 32px to better match header heights and related layout calculations. | |
| // Note: The subtraction of 14 from offsetHeight and the fallback of 32px should be kept in sync with other height calculations (e.g., line 296 subtracts 4px). | |
| resizeHandleHeight = headers.length > 0 ? (headers[0].offsetHeight - 14 ): 32; // fallback to 32px if no headers |
| div.style.cursor = 'col-resize'; | ||
| div.style.userSelect = 'none'; | ||
| div.style.height = (height - 5) + 'px'; | ||
| div.style.height = (height - 4) + 'px'; |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 4 is used here for height calculation (changed from 5). Consider extracting this as a named constant to make the code more maintainable and to clearly document its purpose (e.g., const RESIZE_HANDLE_ADJUSTMENT = 4;).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Fix #4378. The height calculation was don alright already by the header height was set too high because of a padding value. The padding has now been removed. Because of the removed padding, the top of the resize indicator needs to be set dependent on the DataGridDisplayMode