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(1094): Keep current visibility when adding a new entity to the ca… #1615

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tplevko
Copy link
Contributor

@tplevko tplevko commented Nov 11, 2024

…nvas

fixes #1094

vokoscreenNG-2024-11-13_15-03-55.mp4

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 20.00000% with 12 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@39c0ffd). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...sualization/ContextToolbar/NewEntity/NewEntity.tsx 20.00% 12 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1615   +/-   ##
=======================================
  Coverage        ?   79.88%           
  Complexity      ?      273           
=======================================
  Files           ?      280           
  Lines           ?     8030           
  Branches        ?     1541           
=======================================
  Hits            ?     6415           
  Misses          ?     1555           
  Partials        ?       60           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +50 to +53
setTimeout(() => {
const result = findRootVisualization(controller.getGraph(), newId);
controller.fireEvent(SELECTION_EVENT, [result?.id]);
}, 300);
Copy link
Member

Choose a reason for hiding this comment

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

@tplevko we now have the getVisualizationNodesFromGraph function to look for canvas nodes.

      setTimeout(() => {
        const result = getVisualizationNodesFromGraph(
          controller.getGraph(),
          (vizNode) => vizNode.data.entity?.id === newId,
        );

        controller.fireEvent(SELECTION_EVENT, [result[0]?.id]);
      }, 300);

That being said, I don't know a better way to ensure the selection happens after the rerender 😢 , so probably what's gonna happen for environments like DevSpaces, this might fail from time to time, since the SELECTION_EVENT could happen before the actual rerender.

Would you be open to moving forward without the setTimeout for now until we get a better way to ensure the entity is properly selected?

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.

Keep current visibility when adding a new entity to the canvas
2 participants