fix: added an early return on non-existent items (#2571)

This commit is contained in:
ArthurMousatov 2023-07-27 12:03:49 -04:00 committed by GitHub
parent b508ac3d4f
commit 2744f7d5b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -606,10 +606,12 @@ export default {
},
colunmsResize() {
// Update the columns size based on the window width.
let items = css(["#listing.mosaic .item", ".mosaic#listing .item"]);
if (!items) return;
let columns = Math.floor(
document.querySelector("main").offsetWidth / this.columnWidth
);
let items = css(["#listing.mosaic .item", ".mosaic#listing .item"]);
if (columns === 0) columns = 1;
items.style.width = `calc(${100 / columns}% - 1em)`;
},