patternfly-elements icon indicating copy to clipboard operation
patternfly-elements copied to clipboard

[fix] pfe-card: template does not update if light DOM changes

Open kylebuch8 opened this issue 6 years ago • 2 comments

Scenario

If we have a basic card that is just using the default slot. Things work great.

image

<pfe-card>
  Card body copy
</pfe-card>

However, if a header or footer is dynamically added to the pfe-card, the template does not update.

image

image

I added the header and footer with setTimeout after the card has already rendered. You can see the issue on a page here: https://codesandbox.io/s/pfe-card-dynamic-header-footer-dpgxb

Developer Notes

We already have a mutation observer set up in the connectedCallback that's watching the childList. Then in the constructor, we have the callback for the mutation observer. I think if we just called this.render() at the end of the callback, things will work the way we want.

kylebuch8 avatar Mar 06 '20 14:03 kylebuch8

+1 and let's document this approach because most components will need this

castastrophe avatar Mar 11 '20 19:03 castastrophe

Is this still relevant in 2.0? https://patternflyelements.org/components/card/demo/

bennypowers avatar Feb 23 '22 23:02 bennypowers