feat(tracker): field-prefixed search, inline filter chips and zero-hit empty state (#10998)

* feat(tracker): field-prefixed search, inline filter chips and zero-hit empty state

Adds SearchInputAdvanced (field:value prefixes routed to Elasticsearch query_string), match highlighting, inline filter chips with overflow popover, a reusable zero-hit empty state in view-resources, and search-scope/highlight view options for List and Kanban.

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>

* refactor(tracker-search): address review follow-ups on search/filter rework

Shared, non-storage-specific field list, test-folder conventions, locale
coverage, single regex source and an owner-token gate for the result count.

- core: add shared `fullTextSearchFields` constant next to
  FullTextSearchContext as the single source of truth for the full-text
  fields exposed to `field:value` targeting. The client encoder derives
  ES_NATIVE_FIELDS from it and the elastic adapter derives KNOWN_FIELD_RE
  from it, replacing the two "KEEP IN SYNC" copies. Per-field boost weights
  stay a local adapter detail.
- tests: move the five co-located tests into each package's existing test
  folder convention (ui `__test__`, view-resources `__tests__`) and fix the
  relative imports.
- i18n: translate the new tracker search/filter strings in the remaining
  locales (zh, ja, ko, cs, es, fr, it, pt, pt-br, tr), reusing each file's
  existing terminology; ICU placeholders left unchanged.
- encoder: hoist the reserved-character class into one constant and build two
  RegExp instances from it (non-global for `.test()`, global for `.replace()`)
  to avoid the shared-lastIndex trap.
- view-resources: guard `resultIssueCountStore` writes with an owner-token
  gate so a superseded viewlet can no longer clobber the active viewlet's
  count; List/KanbanView claim and release, IssuesView resets through the
  current owner. Assumes a single active IssuesView surface.
- view-resources: make result-count reporting opt-in via a new
  `reportResultCount` prop on List (default true). Embedded, non-primary List
  instances (sub-issues / related issues in the issue edit panel, routed
  through SubIssueList) pass false and never claim the owner token, so opening
  and closing an issue can no longer strand the primary Issues viewlet with a
  dead token — the zero-hit SearchEmptyState card renders again afterwards. Add
  a regression test covering the opted-out embedded consumer.
- elastic: escape every regex metacharacter (not just `.`) when building
  KNOWN_FIELD_RE from `fullTextSearchFields`, so a future field name carrying
  another metacharacter cannot silently corrupt the alternation. Behaviour for
  the current fields is unchanged.

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>

* refactor(tracker-search): centralize regex escaping and lock down result-count store

- Share escapeRegExp from @hcengineering/core so the client encoder and the server elastic adapter escape the fulltext field list identically, not just dots on the client.

- Export resultIssueCountStore as a read-only Readable; the owner-token gate functions (setResultCount / resetResultCount / releaseResultCountOwner) are now the only write path.

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>

---------

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
Co-authored-by: Michael Uray <michaeluray@users.noreply.github.com>
Co-authored-by: Artyom Savchenko <armisav@gmail.com>
This commit is contained in:
Michael Uray
2026-08-11 19:09:33 +07:00
committed by GitHub
co-authored by Michael Uray Artyom Savchenko
parent 5a3d673e84
commit 1be6047c8a
76 changed files with 3341 additions and 195 deletions
@@ -69,6 +69,11 @@ export class CommonTrackerPage extends CalendarPage {
shouldShowAllToggle = (): Locator =>
this.page.locator('.antiCard.menu .antiCard-menu__item:has-text("Show empty groups")')
// Zero-hit search card. Rendered as an out-of-flow overlay centred on the
// panel while the viewlet stays mounted and measurable, so it is on screen
// in List and Kanban alike — assert with toBeInViewport().
searchEmptyStateCard = (): Locator => this.page.locator('.search-empty-state')
header = (): Locator =>
this.page.locator('button.hulyBreadcrumb-container > span.hulyBreadcrumb-label', { hasText: 'Issues' })
@@ -148,7 +148,11 @@ export class IssuesPage extends CommonTrackerPage {
issueName = (name: string): Locator => this.page.locator(`text="${name}"`)
issuesButton = (): Locator => this.page.locator('.antiPanel-navigator').locator('text="Issues"')
viewButton = (): Locator => this.page.locator('button[data-id="btn-viewOptions"]')
orderingButton = (): Locator => this.page.locator('.ordering button')
// The View-Options popup now renders more than one `.ordering` button (the
// Order-by dropdown plus the new searchScope selector). Target the first,
// which is the Order-by control, to keep the locator unambiguous — same fix
// as tracker.utils.ts.
orderingButton = (): Locator => this.page.locator('.ordering button').first()
modifiedDateMenuItem = (): Locator => this.page.locator('button.menu-item', { hasText: 'Modified date' })
estimationContainer = (): Locator => this.page.locator('.estimation-container').first()
addTimeReportButton = (): Locator => this.page.locator('button:has-text("Add time report")')
@@ -381,10 +385,14 @@ export class IssuesPage extends CommonTrackerPage {
for (let i = 0; i < tabs.length; i++) {
await tabs[i].click()
await this.page.waitForTimeout(3000)
// Scope to the actual result link, not the whole panel: on a zero-hit
// tab the SearchEmptyState card legitimately echoes the search term
// ("No issues found for <name>"), which a panel-wide text assertion would
// wrongly match.
if (presence === checks[i]) {
await expect(this.issueListPanel()).toContainText(issueName)
await expect(this.issueAnchorByName(issueName)).toBeVisible()
} else {
await expect(this.issueListPanel()).not.toContainText(issueName)
await expect(this.issueAnchorByName(issueName)).toHaveCount(0)
}
}
}
+30 -1
View File
@@ -1,4 +1,4 @@
import { test } from '@playwright/test'
import { expect, test } from '@playwright/test'
import { CommonTrackerPage } from '../model/tracker/common-tracker-page'
import { IssuesDetailsPage } from '../model/tracker/issues-details-page'
import { IssuesPage } from '../model/tracker/issues-page'
@@ -191,6 +191,35 @@ test.describe('Tracker tests', () => {
await issuesPage.verifyCategoryHeadersVisibilityKanban()
await issuesPage.openViewOptionsAndToggleShouldShowAll()
})
test('list zero-hit search shows the empty-state card unless shouldShowAll is on', async ({ page }) => {
await (
await page.goto(`${PlatformURI}/workbench/sanity-ws/tracker/tracker%3Aproject%3ADefaultProject/issues`)
)?.finished()
const issuesPage = new IssuesPage(page)
await navigate(page)
await issuesPage.navigateToIssues()
await page.click(ViewletSelectors.Table)
// 1) shouldShowAll OFF (default) — zero hits surface the card.
await issuesPage.searchIssueByName('!!!!')
await expect(issuesPage.searchEmptyStateCard()).toBeInViewport()
await expect(issuesPage.searchEmptyStateCard()).toContainText('!!!!')
// 2) shouldShowAll ON — the empty category headers stay visible and the
// card is suppressed, because the explicit view option wins.
await issuesPage.openViewOptionsAndToggleShouldShowAll()
await expect(issuesPage.searchEmptyStateCard()).toHaveCount(0)
// Done / Cancelled only exist in the All mode, same as the
// 'check shouldShowAll option' test above.
await issuesPage.clickModelSelectorAll()
await issuesPage.verifyCategoryHeadersVisibility()
// 3) Toggling back restores the card — proves the option, not the search
// state, is what suppressed it.
await issuesPage.openViewOptionsAndToggleShouldShowAll()
await expect(issuesPage.searchEmptyStateCard()).toBeInViewport()
})
})
async function doSaveViewTest (
panels: string[],
+6 -2
View File
@@ -48,9 +48,13 @@ export async function setViewGroup (page: Page, groupName: string): Promise<void
export async function setViewOrder (page: Page, orderName: string): Promise<void> {
await page.click('button[data-id="btn-viewOptions"]')
await page.click('.antiCard >> .ordering >> button')
// The View-Options popup now renders more than one `.ordering` row: the
// Order-by dropdown plus any "other" toggles/dropdowns (e.g. the new
// searchScope selector). Target the first `.ordering` button, which is the
// Order-by control, to keep the locator unambiguous.
await page.click('.antiCard >> .ordering >> button >> nth=0')
await page.click(`.menu-item:has-text("${orderName}")`)
await expect(page.locator('.antiCard >> .ordering >> button')).toContainText(orderName)
await expect(page.locator('.antiCard >> .ordering >> button >> nth=0')).toContainText(orderName)
await page.keyboard.press('Escape')
}