Take column span into account to determine the max number of columns (#21827)

This commit is contained in:
Paul Bottein 2024-08-29 09:58:17 +02:00 committed by GitHub
parent 87b58b0bbd
commit 2a18706a13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,7 +47,7 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
@state() private _config?: LovelaceViewConfig; @state() private _config?: LovelaceViewConfig;
@state() private _sectionCount = 0; @state() private _sectionColumnCount = 0;
@state() _dragging = false; @state() _dragging = false;
@ -89,9 +89,10 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
} }
private _computeSectionsCount() { private _computeSectionsCount() {
this._sectionCount = this.sections.filter( this._sectionColumnCount = this.sections
(section) => !section.hidden .filter((section) => !section.hidden)
).length; .map((section) => section.config.column_span ?? 1)
.reduce((acc, val) => acc + val, 0);
} }
private _sectionVisibilityChanged = () => { private _sectionVisibilityChanged = () => {
@ -125,7 +126,7 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
const sections = this.sections; const sections = this.sections;
const totalSectionCount = const totalSectionCount =
this._sectionCount + (this.lovelace?.editMode ? 1 : 0); this._sectionColumnCount + (this.lovelace?.editMode ? 1 : 0);
const editMode = this.lovelace.editMode; const editMode = this.lovelace.editMode;
const maxColumnCount = this._columnsController.value ?? 1; const maxColumnCount = this._columnsController.value ?? 1;