Repository navigation
fix: On both workflow pages and standard tool editing pages: if you open the parameter editing window and then close it immediately without saving, any new parameters added subsequently will overwrite the parameters from the cancelled edit session. #7886
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,9 +189,7 @@ function submitCodemirrorEditor(val: string) { | |
| } | ||
|
|
||
| function openAddDialog(data?: any, index?: any) { | ||
| if (typeof index !== 'undefined') { | ||
| currentIndex.value = index | ||
| } | ||
| currentIndex.value = typeof index !== 'undefined' ? index : null | ||
|
|
||
| FieldFormDialogRef.value.open(data) | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the review of the provided code snippet:
Optimization/Suggestion: ✅ Verdict: The change is reasonable if |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a review of the code snippet:
1. Potential Issue: Implicit State Side-Effect on "Close/Reset"
The original logic only updated
currentIndexifindexwas provided. The new logic setscurrentIndextonulleven whenindexis undefined (e.g., opening a "New" item dialog).currentIndexremaining unchanged during certain interactions?openAddDialogis intended only for creating new items or editing specific items in isolation, this change is fine. However, ifcurrentIndextracks state for other purposes, forcing it tonullmight break functionality that expects the previous index to persist when opening a non-specific dialog.2. Type Safety Improvement
currentIndex.value = nullmay cause TypeScript errors ifcurrentIndexis typed asRef<number>orRef<string>instead ofRef<number | null>. Ensure the type definition allowsnull.3. Optimization/Readability
The change from a ternary/conditional block to a single assignment line improves conciseness and maintainability. It reduces branching logic and makes the intent clearer: "If an index is given, use it; otherwise, clear it."
Suggestion:
If the behavior matches your requirements (i.e., opening without an index should reset the current index context), this change is correct and cleaner. Just verify:
currentIndex.valueacceptsnull.currentIndexbeing preserved whenindexis undefined.