Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ticket № 2645
closes #2645
Problem:
Currently, the selected node state is managed through application state, making navigation less predictable and hindering the use of standard browser features (like the Back button). We need to make the node selection mechanism route-based.
Solution:
Implemented a route-based node selection mechanism through a new useSelectedNodeFromUrl hook that synchronizes URL state with the selected node state. This makes node selection more predictable and allows for better browser integration
Changes:
Added new route for selected node: mainroute/episode/{episode_id}/node/{ref_id}
Created useSelectedNodeFromUrl hook for URL state synchronization
Created useNodeNavigation hook to handle node navigation
Integrated the new mechanism into Graph/index.tsx and other components where node selection occurs
Updated existing node selection calls to use the new route-based approach
Testing:
useNodeNavigation tests:
Tests URL formation correctness
Tests node navigation functionality
Tests selected node clearing
useSelectedNodeFromUrl tests:
Tests node setting from URL
Tests node clearing when URL has no ID
Tests invalid ID handling
Notes:
Using replace: true in navigation to prevent unnecessary browser history entries
No state changes occur when node ID from URL is not found
Maintained backward compatibility with existing node selection mechanism
Browser navigation (back/forward) now works seamlessly with node selection