🐛(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.
This commit is contained in:
@@ -31,6 +31,7 @@ and this project adheres to
|
|||||||
- 🐛(frontend) fix empty left panel after deleting root doc #1197
|
- 🐛(frontend) fix empty left panel after deleting root doc #1197
|
||||||
- 🐛(helm) charts generate invalid YAML for collaboration API / WS #890
|
- 🐛(helm) charts generate invalid YAML for collaboration API / WS #890
|
||||||
- 🐛(frontend) 401 redirection overridden #1214
|
- 🐛(frontend) 401 redirection overridden #1214
|
||||||
|
- 🐛(frontend) include root parent in search #1243
|
||||||
|
|
||||||
## [3.4.2] - 2025-07-18
|
## [3.4.2] - 2025-07-18
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { expect, test } from '@playwright/test';
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
import { createDoc, randomName, verifyDocName } from './utils-common';
|
import { createDoc, verifyDocName } from './utils-common';
|
||||||
import { createRootSubPage } from './utils-sub-pages';
|
import { createRootSubPage } from './utils-sub-pages';
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
@@ -163,20 +163,12 @@ test.describe('Document search', () => {
|
|||||||
await verifyDocName(page, firstDocTitle);
|
await verifyDocName(page, firstDocTitle);
|
||||||
|
|
||||||
// Create a new doc - for the moment without children
|
// Create a new doc - for the moment without children
|
||||||
await page.getByRole('button', { name: 'New doc' }).click();
|
const [secondDocTitle] = await createDoc(
|
||||||
await verifyDocName(page, '');
|
page,
|
||||||
await page.getByRole('textbox', { name: 'doc title input' }).click();
|
|
||||||
await page
|
|
||||||
.getByRole('textbox', { name: 'doc title input' })
|
|
||||||
.press('ControlOrMeta+a');
|
|
||||||
const [secondDocTitle] = randomName(
|
|
||||||
'My second sub page search',
|
'My second sub page search',
|
||||||
browserName,
|
browserName,
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
await page
|
|
||||||
.getByRole('textbox', { name: 'doc title input' })
|
|
||||||
.fill(secondDocTitle);
|
|
||||||
|
|
||||||
const searchButton = page
|
const searchButton = page
|
||||||
.getByTestId('left-panel-desktop')
|
.getByTestId('left-panel-desktop')
|
||||||
@@ -199,16 +191,23 @@ test.describe('Document search', () => {
|
|||||||
await page.getByRole('button', { name: 'close' }).click();
|
await page.getByRole('button', { name: 'close' }).click();
|
||||||
|
|
||||||
// Create a sub page
|
// Create a sub page
|
||||||
await createRootSubPage(page, browserName, secondDocTitle);
|
const { name: secondChildDocTitle } = await createRootSubPage(
|
||||||
|
page,
|
||||||
|
browserName,
|
||||||
|
'second - Child doc',
|
||||||
|
);
|
||||||
await searchButton.click();
|
await searchButton.click();
|
||||||
await page
|
await page
|
||||||
.getByRole('combobox', { name: 'Quick search input' })
|
.getByRole('combobox', { name: 'Quick search input' })
|
||||||
.fill('sub page search');
|
.fill('second');
|
||||||
|
|
||||||
// Now there is a sub page - expect to have the focus on the current doc
|
// Now there is a sub page - expect to have the focus on the current doc
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole('presentation').getByLabel(secondDocTitle),
|
page.getByRole('presentation').getByLabel(secondDocTitle),
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
page.getByRole('presentation').getByLabel(secondChildDocTitle),
|
||||||
|
).toBeVisible();
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole('presentation').getByLabel(firstDocTitle),
|
page.getByRole('presentation').getByLabel(firstDocTitle),
|
||||||
).toBeHidden();
|
).toBeHidden();
|
||||||
|
|||||||
@@ -45,6 +45,16 @@ export const DocSearchSubPageContent = ({
|
|||||||
const docsData: QuickSearchData<Doc> = useMemo(() => {
|
const docsData: QuickSearchData<Doc> = useMemo(() => {
|
||||||
const subDocs = subDocsData?.pages.flatMap((page) => page.results) || [];
|
const subDocs = subDocsData?.pages.flatMap((page) => page.results) || [];
|
||||||
|
|
||||||
|
if (treeContext?.root) {
|
||||||
|
const isRootTitleIncludeSearch = treeContext.root?.title
|
||||||
|
?.toLowerCase()
|
||||||
|
.includes(search.toLowerCase());
|
||||||
|
|
||||||
|
if (isRootTitleIncludeSearch) {
|
||||||
|
subDocs.unshift(treeContext.root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
groupName: subDocs.length > 0 ? t('Select a page') : '',
|
groupName: subDocs.length > 0 ? t('Select a page') : '',
|
||||||
elements: search ? subDocs : [],
|
elements: search ? subDocs : [],
|
||||||
@@ -57,7 +67,13 @@ export const DocSearchSubPageContent = ({
|
|||||||
]
|
]
|
||||||
: [],
|
: [],
|
||||||
};
|
};
|
||||||
}, [search, subDocsData, subDocsFetchNextPage, subDocsHasNextPage]);
|
}, [
|
||||||
|
search,
|
||||||
|
subDocsData?.pages,
|
||||||
|
subDocsFetchNextPage,
|
||||||
|
subDocsHasNextPage,
|
||||||
|
treeContext?.root,
|
||||||
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onLoadingChange?.(loading);
|
onLoadingChange?.(loading);
|
||||||
|
|||||||
Reference in New Issue
Block a user