Skip to content

Commit 3475fe4

Browse files
committed
fix(search-replace): move afterReplaceIndexRef write inside handleApply past the guard
1 parent 3aeb9dc commit 3475fe4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,9 @@ export function WorkflowSearchReplace() {
426426
handleSelectMatch(hydratedMatches[nextIndex].id)
427427
}
428428

429-
const handleApply = (matchIds: string[]) => {
429+
const handleApply = (matchIds: string[], replaceActiveIndex?: number) => {
430430
if (!workflowId || isApplying || searchReadOnly) return
431+
if (replaceActiveIndex !== undefined) afterReplaceIndexRef.current = replaceActiveIndex
431432
setIsApplying(true)
432433
let committed = false
433434

@@ -535,8 +536,7 @@ export function WorkflowSearchReplace() {
535536

536537
const handleReplaceActive = () => {
537538
if (!activeMatch) return
538-
afterReplaceIndexRef.current = activeMatchIndex
539-
handleApply([activeMatch.id])
539+
handleApply([activeMatch.id], activeMatchIndex)
540540
}
541541

542542
const handleReplaceAll = () => {

0 commit comments

Comments
 (0)