Skip to content

Commit 30dfea7

Browse files
committed
🐛(frontend) include root parent in search
When searching for documents, the root parent document is now included in the search results if it matches the search query.
1 parent 2cbe363 commit 30dfea7

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to
3131
- 🐛(frontend) fix empty left panel after deleting root doc #1197
3232
- 🐛(helm) charts generate invalid YAML for collaboration API / WS #890
3333
- 🐛(frontend) 401 redirection overridden #1214
34+
- 🐛(frontend) include root parent in search #1243
3435

3536
## [3.4.2] - 2025-07-18
3637

src/frontend/apps/e2e/__tests__/app-impress/doc-search.spec.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, test } from '@playwright/test';
22

3-
import { createDoc, randomName, verifyDocName } from './utils-common';
3+
import { createDoc, verifyDocName } from './utils-common';
44
import { createRootSubPage } from './utils-sub-pages';
55

66
test.beforeEach(async ({ page }) => {
@@ -163,20 +163,12 @@ test.describe('Document search', () => {
163163
await verifyDocName(page, firstDocTitle);
164164

165165
// Create a new doc - for the moment without children
166-
await page.getByRole('button', { name: 'New doc' }).click();
167-
await verifyDocName(page, '');
168-
await page.getByRole('textbox', { name: 'doc title input' }).click();
169-
await page
170-
.getByRole('textbox', { name: 'doc title input' })
171-
.press('ControlOrMeta+a');
172-
const [secondDocTitle] = randomName(
166+
const [secondDocTitle] = await createDoc(
167+
page,
173168
'My second sub page search',
174169
browserName,
175170
1,
176171
);
177-
await page
178-
.getByRole('textbox', { name: 'doc title input' })
179-
.fill(secondDocTitle);
180172

181173
const searchButton = page
182174
.getByTestId('left-panel-desktop')
@@ -199,16 +191,23 @@ test.describe('Document search', () => {
199191
await page.getByRole('button', { name: 'close' }).click();
200192

201193
// Create a sub page
202-
await createRootSubPage(page, browserName, secondDocTitle);
194+
const { name: secondChildDocTitle } = await createRootSubPage(
195+
page,
196+
browserName,
197+
'second - Child doc',
198+
);
203199
await searchButton.click();
204200
await page
205201
.getByRole('combobox', { name: 'Quick search input' })
206-
.fill('sub page search');
202+
.fill('second');
207203

208204
// Now there is a sub page - expect to have the focus on the current doc
209205
await expect(
210206
page.getByRole('presentation').getByLabel(secondDocTitle),
211207
).toBeVisible();
208+
await expect(
209+
page.getByRole('presentation').getByLabel(secondChildDocTitle),
210+
).toBeVisible();
212211
await expect(
213212
page.getByRole('presentation').getByLabel(firstDocTitle),
214213
).toBeHidden();

src/frontend/apps/impress/src/features/docs/doc-search/components/DocSearchSubPageContent.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ export const DocSearchSubPageContent = ({
4545
const docsData: QuickSearchData<Doc> = useMemo(() => {
4646
const subDocs = subDocsData?.pages.flatMap((page) => page.results) || [];
4747

48+
if (treeContext?.root) {
49+
const isRootTitleIncludeSearch = treeContext.root?.title
50+
?.toLowerCase()
51+
.includes(search.toLowerCase());
52+
53+
if (isRootTitleIncludeSearch) {
54+
subDocs.unshift(treeContext.root);
55+
}
56+
}
57+
4858
return {
4959
groupName: subDocs.length > 0 ? t('Select a page') : '',
5060
elements: search ? subDocs : [],
@@ -57,7 +67,13 @@ export const DocSearchSubPageContent = ({
5767
]
5868
: [],
5969
};
60-
}, [search, subDocsData, subDocsFetchNextPage, subDocsHasNextPage]);
70+
}, [
71+
search,
72+
subDocsData?.pages,
73+
subDocsFetchNextPage,
74+
subDocsHasNextPage,
75+
treeContext?.root,
76+
]);
6177

6278
useEffect(() => {
6379
onLoadingChange?.(loading);

0 commit comments

Comments
 (0)