Fix v16 grid position calculation for fractional spans (#112428)
Fix v16 grid position calculation for fractional spans Match frontend span-to-width conversion logic by flooring span first, then multiplying by width factor, instead of multiplying first then flooring. This fixes dashboard layout inconsistencies where panels with fractional spans (e.g. 5.929860088365242) would have different widths between backend and frontend migration paths. - Backend old: Math.floor(5.93 * 2) = Math.floor(11.86) = 11 - Backend new: Math.floor(5.93) * 2 = 5 * 2 = 10 (matches frontend) Includes comprehensive unit test to prevent regression.
This commit is contained in:
@@ -338,7 +338,9 @@ func calculatePanelDimensionsFromSpan(span float64, panel map[string]interface{}
|
||||
}
|
||||
}
|
||||
|
||||
panelWidth := int(math.Floor(span * widthFactor))
|
||||
// Match frontend logic: Math.floor(panel.span) * widthFactor (line 914 in DashboardMigrator.ts)
|
||||
// Frontend floors the span FIRST, then multiplies by widthFactor
|
||||
panelWidth := int(math.Floor(span)) * int(widthFactor)
|
||||
panelHeight := defaultHeight
|
||||
|
||||
if panelHeightValue, hasHeight := panel["height"]; hasHeight {
|
||||
|
||||
Reference in New Issue
Block a user