-
Notifications
You must be signed in to change notification settings - Fork 105
fix(AnalyticalTable): improve scaleWidthMode
"Grow" and "Smart"
#7752
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: main
Are you sure you want to change the base?
Conversation
Size Change: +648 B (+0.14%) Total Size: 448 kB
ℹ️ View Unchanged
|
Pull Request Test Coverage Report for Build 17643841959Details
💛 - Coveralls |
Without the calculation, horizontal virtualization might not work as expected
Pull Request Test Coverage Report for Build 18341189305Details
💛 - Coveralls |
if (scaleWidthMode === AnalyticalTableScaleWidthMode.Smart) { | ||
return calculateSmartColumns(columns, instance, hiddenColumns); | ||
return calculateSmartAndGrowColumns(columns, instance, hiddenColumns); | ||
} | ||
|
||
if (scaleWidthMode === AnalyticalTableScaleWidthMode.Grow) { | ||
return calculateSmartAndGrowColumns(columns, instance, hiddenColumns, true); | ||
} |
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.
Following suggestion:
if (scaleWidthMode === AnalyticalTableScaleWidthMode.Smart) {
const calculatedColumns = calculateSmartAndGrowColumns(visibleColumns, instance, hiddenColumns)
// Map calculated widths back to all columns (including hidden ones)
return columns.map((column) => {
const isHidden = hiddenColumns.includes(column.id ?? column.accessor)
if (isHidden) {
// Return hidden columns unchanged
return column
}
// Find the calculated column
const calculatedColumn = calculatedColumns.find(
(col) => (col.id ?? col.accessor) === (column.id ?? column.accessor)
)
return calculatedColumn || column
})
}
if (scaleWidthMode === AnalyticalTableScaleWidthMode.Grow) {
const calculatedColumns = calculateSmartAndGrowColumns(visibleColumns, instance, hiddenColumns, true)
// Map calculated widths back to all columns (including hidden ones)
return columns.map((column) => {
const isHidden = hiddenColumns.includes(column.id ?? column.accessor)
if (isHidden) {
// Return hidden columns unchanged
return column
}
// Find the calculated column
const calculatedColumn = calculatedColumns.find(
(col) => (col.id ?? col.accessor) === (column.id ?? column.accessor)
)
return calculatedColumn || column
})
}
Explanation: When using the suggested fix in my app, I get flickering hidden columns + hidden columns are shown upon expanding a subrow (tree table).
My best guess would be that when you return fewer columns than you received, react-table thinks columns have been added/removed, triggering a recalculation with different visibleColumns.length and resetting hidden columns.
Hi @Na1k, Thanks for the suggestion! I’ll take a look as soon as possible. Currently I’m busy preparing the next minor release, but we’ll put this fix on hold for now until I had the time to check your suggestion. |
Fixes #7790