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

Add isVisibleNode #21

Merged
merged 2 commits into from
Mar 26, 2020
Merged

Add isVisibleNode #21

merged 2 commits into from
Mar 26, 2020

Conversation

Andreslav
Copy link
Contributor

No description provided.

@alexandrtovmach
Copy link
Member

I'd like to avoid using while loop, because it's not very good way to implement anything like this. If something goes wrong we'll have infinite loop, and it's not good =)
I've also implemented this function, but haven't chance to push it here:

export const isVisibleNode = (node: any): boolean => {
  if (node.visible && node.parent) {
    return isVisibleNode(node.parent);
  } else {
    return node.visible;
  }
};

@sicking
Copy link
Contributor

sicking commented Mar 25, 2020

Nit: you should probably make this function return false if node.parent returns null. That indicates that someone is getting the visibility on a imported component or on a component that has been deleted by that still has instances. In both cases the node is not visible on any page.

@Andreslav
Copy link
Contributor Author

@alexandrtovmach, @sicking Thank you, corrected, taking into account the wishes.

@alexandrtovmach alexandrtovmach merged commit 566d0f3 into master Mar 26, 2020
@alexandrtovmach alexandrtovmach deleted the Add-isVisibleNode branch March 26, 2020 10:19
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.

None yet

3 participants