Skip to content

Commit d23279d

Browse files
committed
fix(search-replace): clear afterReplaceIndexRef on apply failure and zero matches
1 parent 50461fa commit d23279d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/search-replace/workflow-search-replace.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ export function WorkflowSearchReplace() {
383383
prevQueryRef.current = query
384384

385385
if (hydratedMatches.length === 0) {
386+
afterReplaceIndexRef.current = null
386387
if (activeMatchId) setActiveMatchId(null)
387388
usePanelEditorSearchStore.getState().setActiveSearchTarget(null)
388389
return
@@ -431,6 +432,7 @@ export function WorkflowSearchReplace() {
431432
const handleApply = (matchIds: string[]) => {
432433
if (!workflowId || isApplying || searchReadOnly) return
433434
setIsApplying(true)
435+
let committed = false
434436

435437
try {
436438
const selectedIds = new Set(matchIds)
@@ -527,8 +529,10 @@ export function WorkflowSearchReplace() {
527529
message: `Replaced ${replacedCount} field${replacedCount === 1 ? '' : 's'}.`,
528530
workflowId,
529531
})
532+
committed = true
530533
} finally {
531534
setIsApplying(false)
535+
if (!committed) afterReplaceIndexRef.current = null
532536
}
533537
}
534538

0 commit comments

Comments
 (0)