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

Remove duplicates from the expandedNodeMap array #1031

Merged
merged 1 commit into from
Jan 7, 2020

Conversation

jk05
Copy link

@jk05 jk05 commented Dec 31, 2019

fixes: #905

  • There seems to be an issue where the expandedNodeMap contains duplicates, so that as the code recursively loops over the expandedNodeMap array to remove nodes when a node is collapsed, it falls into an issue where the node is not found the second time round during the recursion and throws an error.

  • I'm not sure of where to place a test for this as there didn't seem to be any e2e tests for expanding/closing nodes unless Im mistaken, so any input on that would be appreciated. The other option would be to open a unit test file but I don't want to start cluttering the code base with unnecessary unit test files if they're not needed.

Before - shows the duplicates in the expandedNodeMap:
Screenshot 2020-01-02 at 12 37 31

Before Video

After - shows no duplicates in the expandedNodeMap:

Screenshot 2020-01-02 at 12 38 29

After video

changelog: Fixes viz bug when expand -> dismiss -> expand nodes.

@@ -82,7 +82,7 @@ export default class Graph {
this.nodeMap[eNode.id] = eNode
this._nodes.push(eNode)
this.expandedNodeMap[node.id] = this.expandedNodeMap[node.id]
? this.expandedNodeMap[node.id].concat([eNode.id])
? [...new Set(this.expandedNodeMap[node.id].concat([eNode.id]))]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I have to investigate a little more but I have removed duplicates at this stage and it seems to work. I have to look into the nodes parameter a bit as to why it includes the multiples of the node relationships. It may be that thats where the change is required.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tracked back to https://github.com/neo4j/neo4j-browser/blob/master/src/shared/services/bolt/boltMappings.js#L214 and tried to put in a reduce here to remove duplicates but since this function is used in several places, it seems to cause other issues. So to narrow the scope to the particular problem, Im going to stick with my initial solution for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense and I agree with keeping the scope small.

I think Hugo is tackling it at a lower level in #1003.
So maybe his PR fixes this bug as well @jk05.
Could you have a look if that's the case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill take a look 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled it down locally and the bug still seems to be there...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we can either can look to go ahead with this work to keep the scope smaller, or I can leave a comment on #1003 with a link to this PR (as the context of where Hugo is making the changes could potentially be a better fit than this work). What do you think @oskarhane?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change makes sense 👍

@jk05 jk05 requested a review from oskarhane January 2, 2020 12:48
Copy link
Member

@oskarhane oskarhane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jk05 jk05 merged commit e7937dc into neo4j:master Jan 7, 2020
@jk05 jk05 deleted the after-expand-node-dismissal-error branch January 7, 2020 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After expand if we first dismiss a node then re-expand it throws error
2 participants