-
Notifications
You must be signed in to change notification settings - Fork 83
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
Add min-width on the columns #7557
Changes from all commits
6ad95b1
c5d1b7e
381a67e
fe14b59
5fb99f8
ad254b7
1fa5ab3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,6 +268,7 @@ export const ColumnBaseMixin = (superClass) => | |
static get observers() { | ||
return [ | ||
'_widthChanged(width, _headerCell, _footerCell, _cells)', | ||
'_minWidthChanged(minWidth, _headerCell, _footerCell, _cells)', | ||
'_frozenChanged(frozen, _headerCell, _footerCell, _cells)', | ||
'_frozenToEndChanged(frozenToEnd, _headerCell, _footerCell, _cells)', | ||
'_flexGrowChanged(flexGrow, _headerCell, _footerCell, _cells)', | ||
|
@@ -406,6 +407,17 @@ export const ColumnBaseMixin = (superClass) => | |
}); | ||
} | ||
|
||
/** @private */ | ||
_minWidthChanged(minWidth) { | ||
if (this.parentElement && this.parentElement._columnPropChanged) { | ||
this.parentElement._columnPropChanged('minWidth'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. untested code |
||
} | ||
|
||
this._allCells.forEach((cell) => { | ||
cell.style.minWidth = minWidth; | ||
}); | ||
} | ||
|
||
/** @private */ | ||
_frozenChanged(frozen) { | ||
if (this.parentElement && this.parentElement._columnPropChanged) { | ||
|
@@ -863,6 +875,18 @@ export const GridColumnMixin = (superClass) => | |
value: '100px', | ||
sync: true, | ||
}, | ||
/** | ||
* Min-width of the cells for this column. | ||
* | ||
* Please note that using the `em` length unit is discouraged as | ||
* it might lead to misalignment issues if the header, body, and footer | ||
* cells have different font sizes. Instead, use `rem` if you need | ||
* a length unit relative to the font size. | ||
*/ | ||
minWidth: { | ||
type: String, | ||
sync: true, | ||
}, | ||
|
||
/** | ||
* Flex grow ratio for the cell widths. When set to 0, cell width is fixed. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -409,7 +409,12 @@ export const GridMixin = (superClass) => | |
this.__calculateAndCacheIntrinsicWidths(cols); | ||
|
||
cols.forEach((col) => { | ||
col.width = `${this.__getDistributedWidth(col)}px`; | ||
const calculatedWidth = this.__getDistributedWidth(col); | ||
if (col.minWidth) { | ||
col.width = `max(${col.minWidth}, ${calculatedWidth}px)`; | ||
} else { | ||
col.width = `${calculatedWidth}px`; | ||
} | ||
}); | ||
} | ||
|
||
|
@@ -507,6 +512,17 @@ export const GridMixin = (superClass) => | |
} else { | ||
this._recalculateColumnWidths(cols); | ||
} | ||
// update the columns without autowidth and set the min width | ||
const noAutoWidthCols = this._getColumns().filter((col) => !col.hidden && !col.autoWidth); | ||
|
||
noAutoWidthCols.forEach((col) => { | ||
const calculatedWidth = col.width; | ||
if (col.minWidth) { | ||
col.width = `max(${col.minWidth}, ${calculatedWidth})`; | ||
} else { | ||
col.width = `${calculatedWidth}`; | ||
} | ||
}); | ||
Comment on lines
+515
to
+525
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. untested code |
||
} | ||
|
||
/** @private */ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import '../theme/lumo/lit-all-imports.js'; | ||
import '../src/lit-all-imports.js'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could align with the polymer test and import the styled grid ( |
||
import './column-min-width.common.js'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '../all-imports.js'; | ||
import './column-min-width.common.js'; |
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.
nit: space missing after this line