Multiple canvases which change based on user selection #175
-
Hi, I am trying to create a column layout like in this issue - #56 . In addition to that, I want to allow the user to change the number of columns in the column layout. Since the columns are nested in ‘components.create’ I cannot figure out how to add and delete the number of columns based on user selection. Is this possible ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I'm assuming you want to be able to modify the number of columns after you've dropped the component? If so, you just need to know the Id of that element and add/remove its child node. Ie: // When the user decreases the number of columns
const children = query.node(id).descendants();
if ( children.length > 1 ) {
const lastChildId = children[children.length - 1];
actions.delete(lastChildId);
} |
Beta Was this translation helpful? Give feedback.
-
Hi guys Thanks for the answers. For future readers looking for the same answer, I updated the codesandbox and cleaned it up a bit. |
Beta Was this translation helpful? Give feedback.
I'm assuming you want to be able to modify the number of columns after you've dropped the component?
If so, you just need to know the Id of that element and add/remove its child node. Ie: