Skip to content

Commit b80e095

Browse files
committed
fix(FindReplace): ensure onSearchBarAction is always called without optional chaining
1 parent f2c57f6 commit b80e095

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Shared/Components/CodeEditor/Extensions/findAndReplace.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const FindReplace = ({ view, defaultQuery, defaultShowReplace, onSearchBarAction
111111
wholeWord,
112112
})
113113

114-
onSearchBarAction?.()
114+
onSearchBarAction()
115115
if (!newQuery.eq(query)) {
116116
setQuery(newQuery)
117117
view.dispatch({ effects: setSearchQuery.of(newQuery) })
@@ -121,7 +121,7 @@ const FindReplace = ({ view, defaultQuery, defaultShowReplace, onSearchBarAction
121121

122122
useEffect(() => {
123123
if (!defaultQuery.eq(query)) {
124-
onSearchBarAction?.()
124+
onSearchBarAction()
125125
setMatchesCount(getUpdatedSearchMatchesCount(defaultQuery, view))
126126
setQuery(defaultQuery)
127127
}
@@ -146,15 +146,15 @@ const FindReplace = ({ view, defaultQuery, defaultShowReplace, onSearchBarAction
146146
const onNext = (e?: MouseEvent<HTMLButtonElement>) => {
147147
e?.preventDefault()
148148
e?.stopPropagation()
149-
onSearchBarAction?.()
149+
onSearchBarAction()
150150
findNext(view)
151151
setMatchesCount(getUpdatedSearchMatchesCount(query, view))
152152
}
153153

154154
const onPrevious = (e?: MouseEvent<HTMLButtonElement>) => {
155155
e?.preventDefault()
156156
e?.stopPropagation()
157-
onSearchBarAction?.()
157+
onSearchBarAction()
158158
findPrevious(view)
159159
setMatchesCount(getUpdatedSearchMatchesCount(query, view))
160160
}
@@ -183,7 +183,7 @@ const FindReplace = ({ view, defaultQuery, defaultShowReplace, onSearchBarAction
183183
e.stopPropagation()
184184
if (e.key === 'Enter') {
185185
e.preventDefault()
186-
onSearchBarAction?.()
186+
onSearchBarAction()
187187
replaceNext(view)
188188
}
189189
}
@@ -193,12 +193,12 @@ const FindReplace = ({ view, defaultQuery, defaultShowReplace, onSearchBarAction
193193
}
194194

195195
const onReplaceTextClick = () => {
196-
onSearchBarAction?.()
196+
onSearchBarAction()
197197
replaceNext(view)
198198
}
199199

200200
const onReplaceTextAllClick = () => {
201-
onSearchBarAction?.()
201+
onSearchBarAction()
202202
replaceAll(view)
203203
}
204204

0 commit comments

Comments
 (0)