diff --git a/src/components/document-viewer/source-panels.tsx b/src/components/document-viewer/source-panels.tsx index a725fff38..97e714c5e 100644 --- a/src/components/document-viewer/source-panels.tsx +++ b/src/components/document-viewer/source-panels.tsx @@ -32,8 +32,6 @@ import { cn, codeText, eyebrowText, - fieldControl, - fieldLabel, floatingControl, LoadingPanel, panel, @@ -737,36 +735,53 @@ export function PinnedSourceEvidence({
{chunk.section_heading}
)}{visibleContent || "No displayable clinical text was available for this indexed passage."}-
Source passages
{searchEligible ? ( @@ -1198,7 +1208,7 @@ export const IndexedTextPanel = memo(function IndexedTextPanel({ {documentSearchError} ) : null} -
Enter at least 2 characters to search all indexed passages.
@@ -1239,7 +1249,7 @@ export const IndexedTextPanel = memo(function IndexedTextPanel({
>
{status}
-
+
Page {chunk.page_number ?? "n/a"} · chunk {chunk.chunk_index}
{chunk.serverRanked ? " · full-document search" : ""}
@@ -1263,7 +1273,7 @@ export const IndexedTextPanel = memo(function IndexedTextPanel({
{chunk.section_heading}
) : null}
-
+
{teaser || "No displayable clinical text was available for this indexed passage."}
diff --git a/tests/document-section-summary.dom.test.tsx b/tests/document-section-summary.dom.test.tsx
index a68b58955..421f1a9d1 100644
--- a/tests/document-section-summary.dom.test.tsx
+++ b/tests/document-section-summary.dom.test.tsx
@@ -154,6 +154,65 @@ describe("IndexedTextPanel citation landing", () => {
expect(screen.getByText("Hit 1 of 1")).toBeVisible();
});
+ it("resets the active hit index when the search query changes", async () => {
+ const props = {
+ loading: false,
+ selectedPage: basePage,
+ chunks: [
+ baseChunk,
+ {
+ ...baseChunk,
+ id: "chunk-2",
+ chunk_index: 1,
+ content: "Lithium levels are checked 5 to 7 days after initiation",
+ },
+ ],
+ search: "vom",
+ documentSearchResults: [
+ {
+ id: "chunk-1",
+ page_number: 1,
+ chunk_index: 0,
+ section_heading: "Monitoring",
+ snippet: "Escalate review when there is vomiting",
+ matched_terms: ["vom"],
+ image_ids: [],
+ score: 1,
+ },
+ {
+ id: "chunk-2",
+ page_number: 1,
+ chunk_index: 1,
+ section_heading: "Monitoring",
+ snippet: "Lithium levels are checked 5 to 7 days after initiation",
+ matched_terms: ["vom"],
+ image_ids: [],
+ score: 1,
+ },
+ ],
+ searchingDocument: false,
+ documentSearchError: null,
+ idPrefix: "source-chunk",
+ sectionId: "source-text" as const,
+ onSearchChange: vi.fn(),
+ compact: true,
+ };
+ const { rerender } = render(