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: Fix tool mode switch state persistence in NodeToolbarComponent #5316

Merged
merged 4 commits into from
Dec 17, 2024

Conversation

Cristhianzl
Copy link
Member

This pull request includes several changes to enhance the functionality and user experience of the NodeToolbarComponent and introduces a new test for the tool mode feature. The most important changes include the addition of a new component, refactoring of existing code, and the addition of a new test.

Enhancements to NodeToolbarComponent:

  • Added ToggleShadComponent to the NodeToolbarComponent to allow toggling tool mode directly from the toolbar. [1] [2]
  • Refactored the handleActivateToolMode function to improve readability and maintainability. [1] [2] [3]
  • Introduced memoized values for flowDataNodes, node, and index to optimize performance.

Code Refactoring:

  • Removed unused imports and cleaned up the NodeToolbarComponent file to reduce clutter. [1] [2]
  • Moved the updateNodeInternals declaration to an earlier point in the file to improve code organization. [1] [2]

New Test Addition:

  • Added a new test in tool-mode.spec.ts to verify that users can toggle tool mode and use components as tools. This test ensures that the tool mode functionality works as expected.

Minor UI Improvements:

  • Wrapped the Switch component in a div with an onClick handler to prevent event propagation in the ToggleShadComponent. [1] [2]

…ap Switch component in a div to prevent event propagation

📝 (nodeToolbarComponent/index.tsx): Add ShortcutDisplay component to display keyboard shortcuts for tool mode button
📝 (nodeToolbarComponent/index.tsx): Remove unused imports (CodeAreaModal, ConfirmationModal, EditNodeModal, ShareModal) from NodeToolbarComponent
📝 (nodeToolbarComponent/index.tsx): Remove duplicated declaration of updateNodeInternals function in NodeToolbarComponent
📝 (nodeToolbarComponent/index.tsx): Refactor handleActivateToolMode function to update tool mode value and node data more efficiently
📝 (nodeToolbarComponent/index.tsx): Refactor handleNodeClass function to handle node class changes more efficiently
📝 (nodeToolbarComponent/index.tsx): Refactor postToolModeValue function to post tool mode value to API more efficiently
📝 (nodeToolbarComponent/index.tsx): Refactor renderToolbarButtons to include ShortcutDisplay component for tool mode button and improve button functionality

✨ (tool-mode.spec.ts): Add test for user interaction with components as tools in the application to ensure proper functionality and user experience.
@Cristhianzl Cristhianzl self-assigned this Dec 17, 2024
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Dec 17, 2024
@github-actions github-actions bot added bug Something isn't working and removed enhancement New feature or request labels Dec 17, 2024
Copy link
Contributor

@anovazzi1 anovazzi1 left a comment

Choose a reason for hiding this comment

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

lgtm

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 17, 2024
@Cristhianzl Cristhianzl enabled auto-merge (squash) December 17, 2024 20:53
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Dec 17, 2024
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Dec 17, 2024
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Dec 17, 2024
@Cristhianzl Cristhianzl merged commit 201d6c7 into main Dec 17, 2024
22 checks passed
@Cristhianzl Cristhianzl deleted the cz/fix-toolmode-toggle branch December 17, 2024 22:00
anovazzi1 pushed a commit that referenced this pull request Dec 19, 2024
…5316)

✨ (toggleShadComponent/index.tsx): Refactor ToggleShadComponent to wrap Switch component in a div to prevent event propagation
📝 (nodeToolbarComponent/index.tsx): Add ShortcutDisplay component to display keyboard shortcuts for tool mode button
📝 (nodeToolbarComponent/index.tsx): Remove unused imports (CodeAreaModal, ConfirmationModal, EditNodeModal, ShareModal) from NodeToolbarComponent
📝 (nodeToolbarComponent/index.tsx): Remove duplicated declaration of updateNodeInternals function in NodeToolbarComponent
📝 (nodeToolbarComponent/index.tsx): Refactor handleActivateToolMode function to update tool mode value and node data more efficiently
📝 (nodeToolbarComponent/index.tsx): Refactor handleNodeClass function to handle node class changes more efficiently
📝 (nodeToolbarComponent/index.tsx): Refactor postToolModeValue function to post tool mode value to API more efficiently
📝 (nodeToolbarComponent/index.tsx): Refactor renderToolbarButtons to include ShortcutDisplay component for tool mode button and improve button functionality

✨ (tool-mode.spec.ts): Add test for user interaction with components as tools in the application to ensure proper functionality and user experience.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants