Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/panels/lovelace/views/hui-masonry-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ export class MasonryView extends LitElement implements LovelaceViewElement {
}

protected firstUpdated(): void {
this._updateColumns = this._updateColumns.bind(this);
this._mqls = [300, 600, 900, 1200].map((width) => {
const mql = matchMedia(`(min-width: ${width}px)`);
mql.addEventListener("change", this._updateColumns);
const mql = window.matchMedia(`(min-width: ${width}px)`);
mql.addListener(() => this._updateColumns());
return mql;
});
this._updateColumns();
Expand All @@ -120,10 +119,7 @@ export class MasonryView extends LitElement implements LovelaceViewElement {
if (changedProperties.has("hass")) {
const oldHass = changedProperties.get("hass") as HomeAssistant;

if (
(oldHass && this.hass!.dockedSidebar !== oldHass.dockedSidebar) ||
(!oldHass && this.hass)
) {
if (oldHass && this.hass!.dockedSidebar !== oldHass.dockedSidebar) {
this._updateColumns();
}

Expand Down Expand Up @@ -155,6 +151,10 @@ export class MasonryView extends LitElement implements LovelaceViewElement {
}

private async _createColumns() {
if (!this._columns) {
return;
}

this._createColumnsIteration++;
const iteration = this._createColumnsIteration;
const root = this.shadowRoot!.getElementById("columns")!;
Expand All @@ -168,7 +168,7 @@ export class MasonryView extends LitElement implements LovelaceViewElement {
const columnSizes: number[] = [];
const columnElements: HTMLDivElement[] = [];
// Add columns to DOM, limit number of columns to the number of cards
for (let i = 0; i < Math.min(this._columns!, this.cards.length); i++) {
for (let i = 0; i < Math.min(this._columns, this.cards.length); i++) {
const columnEl = document.createElement("div");
columnEl.classList.add("column");
root.appendChild(columnEl);
Expand Down
2 changes: 1 addition & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,7 @@
"toggle": "Toggle entities.",
"description": "The Entities card is the most common type of card. It groups items together into lists.",
"special_row": "special row",
"edit_special_row": "Edit row using the code editor",
"edit_special_row": "View the details of this row by clicking the edit button",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this

"entity_row_editor": "Entity Row Editor",
"secondary_info_values": {
"none": "No Secondary Info",
Expand Down