Saving empty card breaks UI editor
RenWal opened this issue · 0 comments
RenWal commented
When saving an empty card:
type: custom:vertical-stack-in-card
cards: []
The following JS fails in vertical-stack-in-card.js
, since reduce()
is called on the empty array size
:
async getCardSize() {
await this._cardSize.promise;
const sizes = await Promise.all(this._refCards.map(this._computeCardSize));
return sizes.reduce((a, b) => a + b);
}
At least with my config, this also breaks the Lovelace UI editor such that the card won't be rendered (i.e., you also can't easily delete it anymore) and neither will any cards that you've created after this one. A simple fix seems to be replacing the offending line with return sizes.reduce((a, b) => a + b, 0)
to ensure a default value exists, though I didn't check if that breaks other stuff. At least this lets me see the card in the UI again.