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 version creation / update when opening an action #9145

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

thomtrp
Copy link
Contributor

@thomtrp thomtrp commented Dec 19, 2024

Actions using tiptap trigger updates when called.

Flow is following:

  • component using tiptap receive default value
  • we separate the default value because we need to add specific attributes to the editor when inserting breaks or variables
  • editor performs an update for each value

It means that initialize our editor performs several updates. We need to avoid persisting until the init finished.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR addresses unwanted version updates during TipTap editor initialization by adding state control to prevent premature update triggers.

  • Added isInitializing state in useTextVariableEditor.ts to prevent updates during editor setup
  • Modified onUpdate callback to skip updates while isInitializing is true
  • Improved Enter key handling by moving variable declarations inside multiline condition
  • Added state reset in onCreate callback after content initialization

1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -45,20 +48,23 @@ export const useTextVariableEditor = ({
if (isDefined(defaultValue)) {
initializeEditorContent(editor, defaultValue);
}
setIsInitializing(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: setIsInitializing(false) called before initializeEditorContent completes. Could still trigger unwanted updates.

Copy link
Contributor

@martmull martmull left a comment

Choose a reason for hiding this comment

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

LGTM

@thomtrp thomtrp enabled auto-merge (squash) December 19, 2024 13:09
@thomtrp thomtrp merged commit 5357624 into main Dec 19, 2024
22 checks passed
@thomtrp thomtrp deleted the tt-fix-version-creation-on-tiptap-init branch December 19, 2024 13:19
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.

2 participants