Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/clinical-dashboard/differentials-home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,6 @@ function SearchResultsView({
sortValue={sortValue}
onSortChange={setSortValue}
/>
<UniversalSearchAlsoMatches modeId="differentials" query={query} />
<p
data-testid="differentials-catalogue-notice"
className="flex items-start gap-2 rounded-lg border border-[color:var(--info-border)] bg-[color:var(--info-soft)]/50 px-3 py-1.5 text-xs font-semibold leading-5 text-[color:var(--info)] sm:py-2 sm:text-sm"
Expand Down Expand Up @@ -1142,6 +1141,8 @@ function SearchResultsView({
<DifferentialsMobileCompareBar selectedCount={selectedCount} selectedIds={comparisonIds} query={query} />
) : null}

<UniversalSearchAlsoMatches modeId="differentials" query={query} />

<p className="pb-3 text-center text-xs font-medium text-[color:var(--text-muted)] lg:hidden">
Clinical decision support only. Review before use.
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@ function DocumentSearchResultsPanelImpl({
onSortChange={setSortValue}
/>
</div>
<UniversalSearchAlsoMatches modeId="documents" query={trimmedQuery} />
</>
) : null}
{recordMatchCount > 0 ||
Expand Down Expand Up @@ -1140,6 +1139,8 @@ function DocumentSearchResultsPanelImpl({
</div>
</>
)}

{trimmedQuery && !shouldShowHome ? <UniversalSearchAlsoMatches modeId="documents" query={trimmedQuery} /> : null}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,6 @@ export function FavouritesCommandLibraryPage({ query = "" }: { query?: string })
<div className="hidden lg:block">
<SearchResultsHeaderBand modeId="favourites" query={query} matchCount={scopedItems.length} />
</div>
<UniversalSearchAlsoMatches modeId="favourites" query={query} />

<ActiveFilterChips
searchTerm={query}
selectedTypeId={selectedTypeId}
Expand Down Expand Up @@ -1039,6 +1037,8 @@ export function FavouritesCommandLibraryPage({ query = "" }: { query?: string })
/>
)}

<UniversalSearchAlsoMatches modeId="favourites" query={query} />

<FavouritesMobileBrowseRail
sets={sets}
selectedSetId={effectiveSelectedSetId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ function MedicationResults({
<div className="hidden lg:block">
<SearchResultsHeaderBand modeId="prescribing" query={query} matchCount={resultCount} />
</div>
<UniversalSearchAlsoMatches modeId="prescribing" query={query} className="medication-also-matches" />
<div className="medication-results-inset min-w-0 space-y-2 sm:flex sm:items-end sm:justify-between sm:gap-4 sm:space-y-0">
<div className="min-w-0 space-y-1">
<p className="text-xs font-semibold uppercase text-[color:var(--text-soft)]">Medication search</p>
Expand Down Expand Up @@ -693,6 +692,8 @@ function MedicationResults({
})}
</div>

<UniversalSearchAlsoMatches modeId="prescribing" query={query} className="medication-also-matches" />

<StatusNotice
realDataReady={realDataReady}
authUnavailable={authUnavailable}
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/forms-search-results-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,6 @@ function FormsSearchResultsPageContent({ query }: FormsSearchResultsPageProps) {
onSortChange={setSortValue}
/>
</div>
<UniversalSearchAlsoMatches modeId="forms" query={query} />
{query.trim() && displayedMatches.length === 0 ? (
<SearchResultsEmptyState
modeId="forms"
Expand Down Expand Up @@ -686,6 +685,7 @@ function FormsSearchResultsPageContent({ query }: FormsSearchResultsPageProps) {
</div>
</>
)}
<UniversalSearchAlsoMatches modeId="forms" query={query} />
</>
) : null}
<div className="hidden lg:block">
Expand Down
4 changes: 2 additions & 2 deletions src/components/formulation/formulation-home-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ function FormulationResults({ query }: { query: string }) {
</p>
</header>

<UniversalSearchAlsoMatches modeId="formulation" query={query} />

<section
aria-label="Filter mechanism results"
className="grid gap-2 sm:grid-cols-[minmax(0,1fr)_16rem] sm:items-center"
Expand Down Expand Up @@ -311,6 +309,8 @@ function FormulationResults({ query }: { query: string }) {
</section>
)}

<UniversalSearchAlsoMatches modeId="formulation" query={query} />

<FormulationSafetyNote />
</FormulationPageShell>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/services/services-navigator-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ export function ServicesNavigatorPage() {
sortValue={sortValue}
onSortChange={setSortValue}
/>
<UniversalSearchAlsoMatches modeId="services" query={query} />
</>
}
sidebar={
Expand Down Expand Up @@ -644,6 +643,7 @@ export function ServicesNavigatorPage() {
</div>
</>
)}
<UniversalSearchAlsoMatches modeId="services" query={query} />
</SearchResultsLayout>
);
}
30 changes: 30 additions & 0 deletions tests/ui-universal-search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,36 @@ test.describe("universal search typeahead", () => {
expect(new URL((await universalRequest).url()).searchParams.get("domains")?.split(",")).not.toContain("services");
});

test("places submitted cross-mode matches after the owning mode results", async ({ page }) => {
// "13YARN" matches the demo service fixture so service-search-results renders.
// Use an inline mock that echoes back the same query so universal-also-matches renders.
await page.route(/\/api\/search\/universal(?:\?.*)?$/, async (route) => {
const url = new URL(route.request().url());
const mode = url.searchParams.get("mode") ?? "services";
const q = url.searchParams.get("q") ?? "13YARN";
await fulfillUniversalSearch(route, {
...universalPayload,
query: q,
contextMode: mode,
preferredDomains: [],
domainOrder: universalPayload.groups.map((g) => g.kind),
});
});
await page.goto("/services?q=13YARN&run=1", { waitUntil: "domcontentloaded" });

const results = page.getByTestId("service-search-results");
const alsoMatches = page.getByTestId("universal-also-matches");
await expect(results).toBeVisible();
await expect(alsoMatches).toBeVisible();
expect(
await alsoMatches.evaluate((node) => {
const resultNode = document.querySelector('[data-testid="service-search-results"]');
return Boolean((resultNode?.compareDocumentPosition(node) ?? 0) & Node.DOCUMENT_POSITION_FOLLOWING);
}),
"universal-also-matches panel must appear after primary results in the DOM",
).toBe(true);
});

test("shows submitted cross-mode matches on phones outside hidden desktop headers", async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await mockUniversalSearch(page);
Expand Down
Loading