Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't dynamically add layers to the stage #201

Open
codedealer opened this issue Oct 10, 2022 · 4 comments
Open

Can't dynamically add layers to the stage #201

codedealer opened this issue Oct 10, 2022 · 4 comments

Comments

@codedealer
Copy link

When trying to add a layer to the stage in vue-konva Vue crashes:

[Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core 
  at <VLayer key=2 >

Following by

Uncaught (in promise) DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.

While the error supplies that it's an internal Vue bug I suspect it is still related to how Konva treats layers during the runtime.

Environment:

  • vue 3.2.40
  • vue-konva 3.0.1

Demo to reproduce the error (click "Add layer"):
https://codesandbox.io/s/vibrant-scooby-u20x98

@lavrton
Copy link
Member

lavrton commented Oct 10, 2022

That is the bug in version 3. I wasn't able to find the solution yet. For now, just no use v-for on layers.

It is not recommended to use too many layers any way.

@ryo7000
Copy link

ryo7000 commented Nov 28, 2022

Using v-if on the Layer can cause similar problems.
Please see the demo below.

Demo to reproduce the error (click "Add layer"):
https://codesandbox.io/s/dreamy-allen-90xxxu

After investigating the cause of the problem, I found that removing container.value.innerHTML = ''; from this line eliminates the error.

According to the Vue3 docs, the key is now automatically generated, so removing the DOM would cause problems, right?

@Avarow
Copy link

Avarow commented Sep 7, 2023

Any update or workaround on this issue?

@geoffgscott
Copy link
Contributor

@Avarow This has been a longstanding issue with Vue3 and Konva. I don't think there is any solution other than putting your conditionals inside the v-layer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants