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

Fix navigaton for <div> with extra style #141

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pavlyuts
Copy link
Contributor

@pavlyuts pavlyuts commented Mar 19, 2021

In a case of any extra style applied to <div>, assigned as Editor container, move canva stop work normally:

  1. In the normal mode it work only if click to child drawflow <div>, and won't work if it moved and click goes to prawflow-parent.
  2. In the fxed mode move of canva donot work at all.

All of this becuase code rely on e.target.classList[0], assuming then it is always only one class assigned to any element, and these classes are pre-defined. It looks true for all the elements, created by editor, but it is not true for container <div> which is used to put editor in.

Fix: change e.target.classList[0] to matches() for conditions and add looping over all the classes of the element in the esecution part.

[fbe2125] includes meaningful code change.
[17b7841] Incluses just indents change, coming from the code taken into extra loop.

Hope you found it usefull, this made the code a bit more immue to some factors behind of control.

@jerosoler
Copy link
Owner

Hello @pavlyuts

Thanks for the pull request.

It would not be better to force "parent-drawflow" to be the first class. So we avoid the loop issue.

In the function start.

Something like that:

var elem = document.getElementById('drawflow');
const copyClass = elem.className;
elem.className = ""; // Remove All clases
elem.classList.add("parent-drawflow") // Add class
copyClass.split(" ").forEach(item => elem.classList.add(item)); // Add copied clases

What do you think?

@jerosoler jerosoler self-assigned this Mar 19, 2021
@pavlyuts
Copy link
Contributor Author

pavlyuts commented Mar 19, 2021

Hi!
There should not be any loop issue. Even a loop via all the assigned classes the loop will do nothing on unknown classes but will do what required for every internal class regardless of order. I think my code is more general to resolve the issue.

In other hand, this only matters for top-level container class. You may fix order at the moment of assigning parent-drawflow to ensure it is the first one and this shoud work too.

It is up to you, it is your code, I only wish the issue be fixed ;)

Pls let me know your decision, I may do you way too.

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

Successfully merging this pull request may close these issues.

2 participants