Since the lazy-loading of cards has been introduced, custom-cards stacking other cards can't properly compute the size of the card as the child/children of the custom-card are not defined when getCardSize is called.
getCardSize should be called asynchronously or called after the element has been updated completely.
This is how it is implemented right now in my card:
https://github.com/custom-cards/stack-in-card/blob/master/src/stack-in-card.ts#L120
https://github.com/custom-cards/stack-in-card/blob/master/src/stack-in-card.ts#L148-L150
It should return the size of the child element but always returns 1 because this._card is assigned later on because of the (await HELPERS)
< 0.106Not relevant.
None
getCardSize is used to determine in what column cards should go, calling this later as you suggest would make the layout jump badly.
I understand. But that's a breaking change for custom cards since lazy loading was introduced (didn't happen with 0.105 or before).
I understand, and we should think of a better solution.
getCardSizeis used to determine in what column cards should go, calling this later as you suggest would make the layout jump badly.
After updating to 0.107 it does jump badly even if the layout has only (or mainly) standard cards. Wasn't the case before update.
One solution is that we allow getCardSize to raise an exception with a promise stored on it. If we get this in hui-view we will await that promise and then continue building layout. Maybe include a two second timeout so custom cards can't end up preventing us doing layout
getCardSize would not be defined as the element is not there yet...
Okay so we return element loading promise including firing ll-rebuild?. I think that we should actually not raise an error because that prevents other cards from being loaded. We need to collect them all, see how many are promises, await them all. It's complicated logic
yeah, but ideally start rendering the top cards if they are not promises... So instead of awaiting them all, start awaiting at the first unresolved promise we encounter
I'll go and play with it next week.
Any news on this?
i got some cool vertical stack in cards, but i guess im going to have to revert back to the normal vertical card instead
@RomRider , @ofekashery, how鈥檚 it looking on the new promise based system for vertical-stack-in card or stack-in card? Any chance one of your cards will be fixed?
I鈥檓 trying to decide whether to wait it out, go back to .107.7, or try to hardcode all the card sizes, and would rather not put the work in if there鈥檚 a fix on the horizon. Thanks in advance.
Hi, everyone. @RomRider @ofekashery @balloob: is there any movement on this issue? Thanks
this is closed, don't comment on closed issues.
Most helpful comment
I understand, and we should think of a better solution.