Compare commits

...

4 Commits

Author SHA1 Message Date
Claude 3d271ba1df Clamp the column count to the config instead of caching it in the resize callback 2026-07-25 22:23:13 +00:00
Claude 955d750b4b Merge branch 'dev' into claude/sections-view-column-count 2026-07-25 22:16:39 +00:00
Claude 2d5a8bc5fe Measure the host in the resize callback instead of the observer entries
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KZ6ydA22VeQndgynH4SxCV
2026-07-25 21:48:17 +00:00
Claude 2e4a35a233 Recompute sections view column count when the config changes
The sections view element is reused when navigating between two sections
views, so a view with a different max_columns kept the column count of the
previous view until a resize made the ResizeObserver fire again.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KZ6ydA22VeQndgynH4SxCV
2026-07-25 21:34:02 +00:00
@@ -101,8 +101,7 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
const columns = Math.floor(
(totalWidth - padding + columnGap) / (minColumnWidth + columnGap)
);
const maxColumns = this._config?.max_columns ?? DEFAULT_MAX_COLUMNS;
return clamp(columns, 1, maxColumns);
return Math.max(columns, 1);
},
});
@@ -155,7 +154,14 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
}
private _updateMaxColumnCount(): void {
const maxColumnCount = this._columnsController.value ?? 1;
// The column count is clamped here instead of in the resize callback, so
// that it follows the config of the view the element is currently used for
const maxColumns = this._config?.max_columns ?? DEFAULT_MAX_COLUMNS;
const maxColumnCount = clamp(
this._columnsController.value ?? 1,
1,
maxColumns
);
if (maxColumnCount !== this._maxColumns) {
this._maxColumns = maxColumnCount;