From a6b8e8b8a77188b3b7d84e34690be22cd2250187 Mon Sep 17 00:00:00 2001
From: Eric Mc Sween <5454374+emcsween@users.noreply.github.com>
Date: Wed, 16 Apr 2025 10:48:25 -0400
Subject: [PATCH] Merge pull request #24930 from
overleaf/em-ae-jd-full-project-search-launch
Launch full project search from regular search
GitOrigin-RevId: 3ef4f6923a0aeef6ab68768bab79e4be32f09eb0
---
.../features/event-tracking/search-events.ts | 5 ++-
.../components/codemirror-search-form.tsx | 38 +++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/services/web/frontend/js/features/event-tracking/search-events.ts b/services/web/frontend/js/features/event-tracking/search-events.ts
index 9829a2024e..cd9ff4b8ba 100644
--- a/services/web/frontend/js/features/event-tracking/search-events.ts
+++ b/services/web/frontend/js/features/event-tracking/search-events.ts
@@ -4,7 +4,10 @@ type SearchEventSegmentation = {
'search-open':
| ({
searchType: 'full-project'
- } & ({ method: 'keyboard' } | { method: 'button'; location: 'toolbar' }))
+ } & (
+ | { method: 'keyboard' }
+ | { method: 'button'; location: 'toolbar' | 'search-form' }
+ ))
| ({
searchType: 'document'
mode: 'visual' | 'source'
diff --git a/services/web/frontend/js/features/source-editor/components/codemirror-search-form.tsx b/services/web/frontend/js/features/source-editor/components/codemirror-search-form.tsx
index a51075cb46..21825ee25d 100644
--- a/services/web/frontend/js/features/source-editor/components/codemirror-search-form.tsx
+++ b/services/web/frontend/js/features/source-editor/components/codemirror-search-form.tsx
@@ -21,9 +21,11 @@ import MaterialIcon from '@/shared/components/material-icon'
import OLButtonGroup from '@/features/ui/components/ol/ol-button-group'
import OLFormControl from '@/features/ui/components/ol/ol-form-control'
import OLCloseButton from '@/features/ui/components/ol/ol-close-button'
+import { isSplitTestEnabled } from '@/utils/splitTestUtils'
import { useTranslation } from 'react-i18next'
import classnames from 'classnames'
import { useUserSettingsContext } from '@/shared/context/user-settings-context'
+import { useLayoutContext } from '@/shared/context/layout-context'
import { getStoredSelection, setStoredSelection } from '../extensions/search'
import { debounce } from 'lodash'
import { EditorSelection, EditorState } from '@codemirror/state'
@@ -49,6 +51,7 @@ type MatchPositions = {
const CodeMirrorSearchForm: FC = () => {
const view = useCodeMirrorViewContext()
const state = useCodeMirrorStateContext()
+ const { setProjectSearchIsOpen } = useLayoutContext()
const { userSettings } = useUserSettingsContext()
const emacsKeybindingsActive = userSettings.mode === 'emacs'
@@ -223,6 +226,16 @@ const CodeMirrorSearchForm: FC = () => {
return getSearchQuery(state)
}, [state])
+ const openFullProjectSearch = useCallback(() => {
+ setProjectSearchIsOpen(true)
+ closeSearchPanel(view)
+ window.setTimeout(() => {
+ window.dispatchEvent(
+ new CustomEvent('editor:full-project-search', { detail: query })
+ )
+ }, 200)
+ }, [setProjectSearchIsOpen, query, view])
+
const showReplace = !state.readOnly
return (
@@ -424,6 +437,31 @@ const CodeMirrorSearchForm: FC = () => {
+ {isSplitTestEnabled('full-project-search') ? (
+