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

@tplevko tplevko force-pushed the issue_1094 branch 2 times, most recently from 7ac6697 to 371de49 Compare November 15, 2024 12:03
Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.

Project coverage is 78.47%. Comparing base (d3299a6) to head (818e414).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...sualization/ContextToolbar/NewEntity/NewEntity.tsx 57.14% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1615      +/-   ##
============================================
- Coverage     78.48%   78.47%   -0.02%     
  Complexity      367      367              
============================================
  Files           468      468              
  Lines         14778    14784       +6     
  Branches       2746     2831      +85     
============================================
+ Hits          11599    11602       +3     
- Misses         3091     3094       +3     
  Partials         88       88              

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

Comment on lines 50 to 38
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?

@tplevko tplevko force-pushed the issue_1094 branch 2 times, most recently from 1640aff to d7ad43b Compare January 10, 2025 12:15
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