Skip to content

Conversation

amanmahajan7
Copy link
Collaborator

@amanmahajan7 amanmahajan7 commented Mar 16, 2022

Cherry picked changes from #2839

@amanmahajan7 amanmahajan7 self-assigned this Mar 16, 2022
@amanmahajan7 amanmahajan7 changed the title Fix width Fix min/max width Mar 16, 2022
@codecov
Copy link

codecov bot commented Mar 16, 2022

Codecov Report

Merging #2855 (824e9a5) into main (cb4c389) will not change coverage.
The diff coverage is 95.65%.

@@           Coverage Diff           @@
##             main    #2855   +/-   ##
=======================================
  Coverage   96.22%   96.22%           
=======================================
  Files          37       38    +1     
  Lines        1244     1244           
  Branches      392      391    -1     
=======================================
  Hits         1197     1197           
  Misses         47       47           
Impacted Files Coverage Δ
src/Columns.tsx 100.00% <ø> (ø)
src/DataGrid.tsx 94.44% <0.00%> (ø)
src/HeaderCell.tsx 90.00% <100.00%> (-0.15%) ⬇️
src/hooks/useCalculatedColumns.ts 99.16% <100.00%> (-0.03%) ⬇️
src/utils/index.ts 88.88% <100.00%> (-3.97%) ⬇️
src/utils/styleUtils.ts 100.00% <100.00%> (ø)

@amanmahajan7 amanmahajan7 marked this pull request as ready for review March 16, 2022 21:55
@amanmahajan7 amanmahajan7 requested a review from nstepien as a code owner March 16, 2022 21:55
isLastFrozenColumn: false,
rowGroup,
width: rawColumn.width ?? defaultWidth,
minWidth: rawColumn.minWidth ?? defaultMinWidth,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This way we initialize widths once and use them everywhere
https://github.com/adazzle/react-data-grid/blob/main/src/HeaderCell.tsx#L178

key: SELECT_COLUMN_KEY,
name: '',
width: 35,
minWidth: 35,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Needed now as the default min width is 80

{ selector: 'typeLike', format: ['PascalCase'] }
],
// TODO: fix
'@typescript-eslint/naming-convention': 0,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if this a bug or needs to be tweaked

const width = isRtl ? right + offset - event.clientX : event.clientX + offset - left;
if (width > 0) {
onColumnResize(column, width);
onColumnResize(column, clampColumnWidth(width, column));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Otherwise DataGrid.onColumnResize is called with wrong width as it does not respect min/max width

@@ -0,0 +1,40 @@
import type { CSSProperties } from 'react';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved style utils to a separate file

@amanmahajan7 amanmahajan7 merged commit 27908f2 into main Mar 31, 2022
@amanmahajan7 amanmahajan7 deleted the am-fix-width branch March 31, 2022 15:39
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