Replies: 1 comment 2 replies
-
Q1 I think you need to change the traits target to the new Component |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Trying to implement a way for users to "group" blocks. Essentially creating a new component/block on the fly.
Using a Navbar as example, the flow would be :
That's the basic premise and I have it mostly working fine except for the traits. for some reason I'm getting strange behaviour.
Here's a basic example of what I'm doing:
Now, this is mostly working fine (but please if you see anything questionable let me know!)
But there's issues with the traits, traits using changeProp: 0 seem to be fine but all with changeProp: 1 are problematic. I've tried adding them as above and this causes them to completely stop functioning. If I comment out that line, then the traits are copied over (due to extending the original???) and still work although they seem to lose "sync" with the component they are attached to.
For example, our Navbar has a trait that adds a class to the
<nav/>
element, simple stuff:`
Currently the result is:
Thrown together a basic gist: https://jsfiddle.net/20okd7tn/7/
It doesn't have the ability to update the blocks but I'm sure the problems I'm having are derived from the initial way i'm "cloning" the original block.
to use:
Q1: At a guess it seems that every way I've tried to copy the traits over from original to new results in the traits still referencing the original component?? Any tips on copying traits from a component and maintaining the values
Q2: Surely there's a better way of copying the original component instead of recursion down through its components?
Any tips/help would be very much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions