Skip to content

Bug fix - Clear current service state on browser "back" button press #933#941

Open
ruwinirathnamalala wants to merge 3 commits intobuerokratt:devfrom
rootcodelabs:bug-fix/933
Open

Bug fix - Clear current service state on browser "back" button press #933#941
ruwinirathnamalala wants to merge 3 commits intobuerokratt:devfrom
rootcodelabs:bug-fix/933

Conversation

@ruwinirathnamalala
Copy link
Collaborator

This pull request introduces improvements to state management and initialization for the service flow functionality. The main changes ensure proper cleanup of state when navigating away from the page and enhance the default structure of new services.

State management improvements:

  • Added a cleanup function in the ServiceFlowPage component to reset the service store state when the component unmounts, ensuring consistent behavior including when using the browser back button.

Service initialization enhancements:

  • Modified the service store's default state to include empty examples and entities arrays for new services, improving the clarity and completeness of the initial service object.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

const initialHistoryState = {
nodes: JSON.parse(JSON.stringify(nodes)),
edges: JSON.parse(JSON.stringify(edges)),
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The structuredClone approach failed with DataCloneError because flow nodes contain function references (onDelete, onEdit, setClickedNode, update), which cannot be cloned by the structured clone algorithm. The JSON.parse(JSON.stringify()) method is used here to strip functions from nodes before saving to history, which are then manually re-attached during undo/redo operations.

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.

[BUG] Clear current service state on browser "back" button press

2 participants