Skip to content

Issues with Graph Updates if Links is Empty Array #615

@Username26

Description

@Username26

Describe the bug
If the user passes an empty array to the links input, the ngOnChanges hook does not
trigger the "update" function.

To Reproduce
Steps to reproduce the behavior:

  1. create test data, where links is an empty array
  2. render graph with test data from step 1
  3. set a breakpoint at the call of the "update" function within the ngOnChanges hook
  4. change the input value for zoomLevel (or do anything else, that triggers the ngOnChanges hook of the graph.component.ts)
  5. breakpoint is not reached and so "update" function is not triggered => this is what I consider the bug

Expected behavior
"update" should be called, even if the graph contains no links, i.e. if the graph is only a single node.

Demo
If needed I can try to provide one upon request.

ngx-graph version
10.0.0

Additional context
In our specific case, this is causing our graph to disappear, whenever we're updating the zoomLevel, if we don't have any edges. Now there is likely something more to it on our side, since I tried modifying an older stackblitz demo to pass an empty links array, and the graph didn't disappear. But nonetheless I would like to ask why "this.links.length" is evaluated in the conditional clause of the ngOnChanges hook? I would argue, that a single node is a valid state and "update" should still be called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions