From c498d7f9c9d079ee5bb2083c5a039ff922a7afc7 Mon Sep 17 00:00:00 2001 From: harshita-jangra Date: Thu, 26 Nov 2026 00:02:29 +0530 Subject: [PATCH 1/3] Show when menu search has more results --- packages/pivotkit-react/src/levels.jsx | 18 +++++++--- packages/pivotkit-react/src/menu-labels-de.js | 1 + packages/pivotkit-react/src/menu-labels.js | 1 + packages/pivotkit-react/src/menu-topics.js | 35 +++++++++++++++---- .../pivotkit-react/test/menu-topics.test.js | 5 ++- 5 files changed, 48 insertions(+), 12 deletions(-) diff --git a/packages/pivotkit-react/src/levels.jsx b/packages/pivotkit-react/src/levels.jsx index f7a629158..0f765ad9d 100644 --- a/packages/pivotkit-react/src/levels.jsx +++ b/packages/pivotkit-react/src/levels.jsx @@ -19,7 +19,7 @@ import { ClearInput } from "./clear-input.jsx"; import { HelpContext } from "./help.js"; import { Group } from "./popover.jsx"; import { SettingInfo } from "./section.jsx"; -import { rowName, searchEntries, searchHits, stepIndex, typeAheadIndex } from "./menu-topics.js"; +import { rowName, searchEntries, searchHits, searchHasMore, SEARCH_HITS, stepIndex, typeAheadIndex } from "./menu-topics.js"; /** * A scrolling part of a menu (the first level's list, a topic's level), marked while more of it lies @@ -458,7 +458,7 @@ function TopicFirst({ topic, labels, onPick, onOpen }) { * The search of a menu: every choice of every level, by its text and its path. Enter runs only a hit * the arrow keys moved to; nothing found says so. */ -function SearchHits({ hits, labels, onPick, onOpen, close }) { +function SearchHits({ hits, labels, onPick, onOpen, close, hasMore }) { if (!hits.length) { return (

@@ -466,12 +466,18 @@ function SearchHits({ hits, labels, onPick, onOpen, close }) {

); } - return ( + return (<> {hits.map((h) => ( (h.choice ? onPick(h.choice) : onOpen(h.topic.id, undefined, h.focus))} /> ))} + {hasMore ? ( +

+ {fill(labels.searchMore, { count: SEARCH_HITS })} +

+ ) : null} + ); } @@ -574,7 +580,9 @@ export function LevelMenu({ name, labels, topics, close, onPick, panel, head, fo const first = () => { const typed = search && query.trim() ? query : ""; const shown = typed && filter ? filter(typed) : topics; - const hits = typed && !filter ? searchHits(searchEntries(topics, query), query, labels.lang) : null; + const entries = typed && !filter ? searchEntries(topics, query) : null; + const hits = entries ? searchHits(entries, query, labels.lang) : null; + const hasMore = entries ? searchHasMore(entries, query, labels.lang) : false; const none = typed && filter && !shown.some((t) => !t.hidden && (t.groups ?? []).some((g) => g.choices.length)); return ( <> @@ -608,7 +616,7 @@ export function LevelMenu({ name, labels, topics, close, onPick, panel, head, fo ) : null} {hits || none ? ( - + ) : ( {shown.map((t) => ( diff --git a/packages/pivotkit-react/src/menu-labels-de.js b/packages/pivotkit-react/src/menu-labels-de.js index 8f1826d81..232b7803e 100644 --- a/packages/pivotkit-react/src/menu-labels-de.js +++ b/packages/pivotkit-react/src/menu-labels-de.js @@ -40,6 +40,7 @@ export const de = { searchMenuShort: "In diesem Menü suchen (Taste /)", searchResults: "Treffer", searchNothing: "Nichts gefunden. Ein anderes Wort versuchen oder die Suche leeren.", + searchMore: "Es werden nur die ersten {count} Treffer angezeigt. Schränke die Suche ein, um weniger Treffer zu erhalten.", addAlready: "Bereits in {zone}.", addMoves: "Verschiebt es aus {zone}.", addSecond: "Fügt einen zweiten Wert davon hinzu.", diff --git a/packages/pivotkit-react/src/menu-labels.js b/packages/pivotkit-react/src/menu-labels.js index e0396b613..709f2fa40 100644 --- a/packages/pivotkit-react/src/menu-labels.js +++ b/packages/pivotkit-react/src/menu-labels.js @@ -46,6 +46,7 @@ export const en = { searchMenuShort: "Search in this menu (key /)", searchResults: "Results", searchNothing: "Nothing found. Try another word, or clear the search.", + searchMore: "Only the first {count} results are shown. Narrow your search to see fewer results.", // the menu of "+ Add" in a zone: a field there already, one that moves, a second value addAlready: "Already in {zone}.", addMoves: "Moves it from {zone}.", diff --git a/packages/pivotkit-react/src/menu-topics.js b/packages/pivotkit-react/src/menu-topics.js index 5ddc5c9e0..538529825 100644 --- a/packages/pivotkit-react/src/menu-topics.js +++ b/packages/pivotkit-react/src/menu-topics.js @@ -842,28 +842,51 @@ export function searchEntries(topics, query = "") { export const SEARCH_HITS = 8; /** - * The entries every word of `query` is found in (its text or its path), at most SEARCH_HITS; those - * whose text starts with the query first. + * All matching entries in search order. * @param {SearchEntry[]} entries * @param {string} query * @param {string} [locale] * @returns {SearchEntry[]} */ -export function searchHits(entries, query, locale) { +function matchingSearchHits(entries, query, locale) { const lower = (s) => s.toLocaleLowerCase(locale); const words = lower(query).split(/\s+/).filter(Boolean); + if (!words.length) { return []; } + const found = entries.filter((e) => { const text = lower(`${e.text} ${e.path} ${e.topic.keywords ?? ""} ${e.choice?.keywords ?? e.keywords ?? ""}`); return words.every((w) => text.includes(w)); }); - // a stable sort: the entries with the first word among their own keywords ("percent": the shares - // of Show as), then those whose text starts with it, in their order, then the rest + const own = (/** @type {SearchEntry} */ e) => lower(e.choice?.keywords ?? "").split(/\s+/).includes(words[0]); const rank = (/** @type {SearchEntry} */ e) => (own(e) ? 0 : lower(e.text).startsWith(words[0]) ? 1 : 2); - return [0, 1, 2].flatMap((r) => found.filter((e) => rank(e) === r)).slice(0, SEARCH_HITS); + + return [0, 1, 2].flatMap((r) => found.filter((e) => rank(e) === r)); +} + +/** + * The first SEARCH_HITS matching entries. + * @param {SearchEntry[]} entries + * @param {string} query + * @param {string} [locale] + * @returns {SearchEntry[]} + */ +export function searchHits(entries, query, locale) { + return matchingSearchHits(entries, query, locale).slice(0, SEARCH_HITS); +} + +/** + * Whether more matching entries exist beyond the displayed limit. + * @param {SearchEntry[]} entries + * @param {string} query + * @param {string} [locale] + * @returns {boolean} + */ +export function searchHasMore(entries, query, locale) { + return matchingSearchHits(entries, query, locale).length > SEARCH_HITS; } /** diff --git a/packages/pivotkit-react/test/menu-topics.test.js b/packages/pivotkit-react/test/menu-topics.test.js index fd21e2057..a726d24c8 100644 --- a/packages/pivotkit-react/test/menu-topics.test.js +++ b/packages/pivotkit-react/test/menu-topics.test.js @@ -6,7 +6,7 @@ import { encode, normalize } from "pivotkit-core"; // the German first-load texts: pivotkit-react adds them as it loads (deferred.js) import "../src/deferred.js"; import { setItemFilter, setTopFilter, setValueFilter } from "../src/menu-ops.js"; -import { afterDelete, axisTopics, entryIds, formatLabel, moreTopics, rowFoldTexts, rowName, searchEntries, searchHits, SEARCH_HITS, stepIndex, tableTopics, TOP_COUNTS, topText, typeAheadIndex, valueTopics } from "../src/menu-topics.js"; +import { afterDelete, axisTopics, entryIds, formatLabel, moreTopics, rowFoldTexts, rowName, searchEntries, searchHits, SEARCH_HITS, searchHasMore, stepIndex, tableTopics, TOP_COUNTS, topText, typeAheadIndex, valueTopics } from "../src/menu-topics.js"; import { MENU } from "./helpers.js"; const data = encode([ @@ -209,6 +209,9 @@ test("search: every choice of every level with its path, and the panels; all wor assert.deepEqual(hit(" "), []); assert.deepEqual(hit("nothing like this"), []); assert.ok(searchHits(entries, "o", "en-US").length <= SEARCH_HITS); + assert.equal(searchHasMore(entries, "o", "en-US"), true); + assert.equal(searchHasMore(entries, "currency", "en-US"), false); + assert.equal(searchHasMore(entries, " ", "en-US"), false); // a field's: the Filter panel is an entry that opens it const field = searchEntries(axis(view)); // the Filter panel's own entries (its rules) are found by its title too From 1a352a09c9909b1290bbd35cfe4afe7ea364f26a Mon Sep 17 00:00:00 2001 From: harshita-jangra Date: Thu, 26 Nov 2026 12:24:34 +0530 Subject: [PATCH 2/3] fix: improve menu search result limit message --- packages/pivotkit-react/CHANGELOG.md | 3 ++ packages/pivotkit-react/src/levels.jsx | 9 +++-- packages/pivotkit-react/src/menu-labels-de.js | 2 +- packages/pivotkit-react/src/menu-labels.js | 2 +- packages/pivotkit-react/src/menu-topics.js | 37 ++++++------------- .../pivotkit-react/test/filter-rules.test.js | 18 ++++----- .../pivotkit-react/test/menu-topics.test.js | 20 +++++----- 7 files changed, 41 insertions(+), 50 deletions(-) diff --git a/packages/pivotkit-react/CHANGELOG.md b/packages/pivotkit-react/CHANGELOG.md index 8f5ddd426..2fe424eb0 100644 --- a/packages/pivotkit-react/CHANGELOG.md +++ b/packages/pivotkit-react/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to `pivotkit-react` are documented in this file. The format [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed + +- The menu search says when it shows only the first 8 results. ## [0.10.0] - 2026-11-24 diff --git a/packages/pivotkit-react/src/levels.jsx b/packages/pivotkit-react/src/levels.jsx index 0f765ad9d..9995a4d9a 100644 --- a/packages/pivotkit-react/src/levels.jsx +++ b/packages/pivotkit-react/src/levels.jsx @@ -19,7 +19,7 @@ import { ClearInput } from "./clear-input.jsx"; import { HelpContext } from "./help.js"; import { Group } from "./popover.jsx"; import { SettingInfo } from "./section.jsx"; -import { rowName, searchEntries, searchHits, searchHasMore, SEARCH_HITS, stepIndex, typeAheadIndex } from "./menu-topics.js"; +import { rowName, searchEntries, searchHits, SEARCH_HITS, stepIndex, typeAheadIndex } from "./menu-topics.js"; /** * A scrolling part of a menu (the first level's list, a topic's level), marked while more of it lies @@ -581,8 +581,9 @@ export function LevelMenu({ name, labels, topics, close, onPick, panel, head, fo const typed = search && query.trim() ? query : ""; const shown = typed && filter ? filter(typed) : topics; const entries = typed && !filter ? searchEntries(topics, query) : null; - const hits = entries ? searchHits(entries, query, labels.lang) : null; - const hasMore = entries ? searchHasMore(entries, query, labels.lang) : false; + const result = entries ? searchHits(entries, query, labels.lang) : null; + const hits = result?.hits ?? null; + const hasMore = result?.hasMore ?? false; const none = typed && filter && !shown.some((t) => !t.hidden && (t.groups ?? []).some((g) => g.choices.length)); return ( <> @@ -616,7 +617,7 @@ export function LevelMenu({ name, labels, topics, close, onPick, panel, head, fo ) : null} {hits || none ? ( - + ) : ( {shown.map((t) => ( diff --git a/packages/pivotkit-react/src/menu-labels-de.js b/packages/pivotkit-react/src/menu-labels-de.js index 232b7803e..f1702eee6 100644 --- a/packages/pivotkit-react/src/menu-labels-de.js +++ b/packages/pivotkit-react/src/menu-labels-de.js @@ -40,7 +40,7 @@ export const de = { searchMenuShort: "In diesem Menü suchen (Taste /)", searchResults: "Treffer", searchNothing: "Nichts gefunden. Ein anderes Wort versuchen oder die Suche leeren.", - searchMore: "Es werden nur die ersten {count} Treffer angezeigt. Schränke die Suche ein, um weniger Treffer zu erhalten.", + searchMore: "Nur die ersten {count} Treffer. Mehr Wörter grenzen die Suche ein.", addAlready: "Bereits in {zone}.", addMoves: "Verschiebt es aus {zone}.", addSecond: "Fügt einen zweiten Wert davon hinzu.", diff --git a/packages/pivotkit-react/src/menu-labels.js b/packages/pivotkit-react/src/menu-labels.js index 709f2fa40..3fab9bdbb 100644 --- a/packages/pivotkit-react/src/menu-labels.js +++ b/packages/pivotkit-react/src/menu-labels.js @@ -46,7 +46,7 @@ export const en = { searchMenuShort: "Search in this menu (key /)", searchResults: "Results", searchNothing: "Nothing found. Try another word, or clear the search.", - searchMore: "Only the first {count} results are shown. Narrow your search to see fewer results.", + searchMore: "Only the first {count} results are shown. Type more to narrow the search.", // the menu of "+ Add" in a zone: a field there already, one that moves, a second value addAlready: "Already in {zone}.", addMoves: "Moves it from {zone}.", diff --git a/packages/pivotkit-react/src/menu-topics.js b/packages/pivotkit-react/src/menu-topics.js index 538529825..06c9027be 100644 --- a/packages/pivotkit-react/src/menu-topics.js +++ b/packages/pivotkit-react/src/menu-topics.js @@ -842,18 +842,19 @@ export function searchEntries(topics, query = "") { export const SEARCH_HITS = 8; /** - * All matching entries in search order. + * The entries every word of `query` is found in (its text or its path), at most SEARCH_HITS; those + * whose text starts with the query first, and whether more matches exist. * @param {SearchEntry[]} entries * @param {string} query * @param {string} [locale] - * @returns {SearchEntry[]} + * @returns {{ hits: SearchEntry[], hasMore: boolean }} */ -function matchingSearchHits(entries, query, locale) { +export function searchHits(entries, query, locale) { const lower = (s) => s.toLocaleLowerCase(locale); const words = lower(query).split(/\s+/).filter(Boolean); if (!words.length) { - return []; + return { hits: [], hasMore: false }; } const found = entries.filter((e) => { @@ -861,33 +862,19 @@ function matchingSearchHits(entries, query, locale) { return words.every((w) => text.includes(w)); }); + // a stable sort: the entries with the first word among their own keywords ("percent": the shares + // of Show as), then those whose text starts with it, in their order, then the rest const own = (/** @type {SearchEntry} */ e) => lower(e.choice?.keywords ?? "").split(/\s+/).includes(words[0]); const rank = (/** @type {SearchEntry} */ e) => (own(e) ? 0 : lower(e.text).startsWith(words[0]) ? 1 : 2); - return [0, 1, 2].flatMap((r) => found.filter((e) => rank(e) === r)); -} + const all = [0, 1, 2].flatMap((r) => found.filter((e) => rank(e) === r)); -/** - * The first SEARCH_HITS matching entries. - * @param {SearchEntry[]} entries - * @param {string} query - * @param {string} [locale] - * @returns {SearchEntry[]} - */ -export function searchHits(entries, query, locale) { - return matchingSearchHits(entries, query, locale).slice(0, SEARCH_HITS); + return { + hits: all.slice(0, SEARCH_HITS), + hasMore: all.length > SEARCH_HITS, + }; } -/** - * Whether more matching entries exist beyond the displayed limit. - * @param {SearchEntry[]} entries - * @param {string} query - * @param {string} [locale] - * @returns {boolean} - */ -export function searchHasMore(entries, query, locale) { - return matchingSearchHits(entries, query, locale).length > SEARCH_HITS; -} /** * A row's accessible name: "Filter, 3 of 12, changed" (`changedWord`: ", changed"). diff --git a/packages/pivotkit-react/test/filter-rules.test.js b/packages/pivotkit-react/test/filter-rules.test.js index d04404bd7..d47209b9e 100644 --- a/packages/pivotkit-react/test/filter-rules.test.js +++ b/packages/pivotkit-react/test/filter-rules.test.js @@ -274,7 +274,7 @@ test("the data's share of a range names no day from today on: they have no data test("search: quick choices with the count typed, a year compared, and the rules by name; they apply at once", () => { const topics = axisTopics({ view: byYear, zone: "rows", index: 0, field: YEAR, types, labels: MENU.en, locale: "en-US", encoded: data }); - const hits = (q) => searchHits(searchEntries(topics, q), q, "en-US"); + const hits = (q) => searchHits(searchEntries(topics, q), q, "en-US").hits; const years = relativeDateRange("year", 2); const last2 = hits("last 2 years")[0]; // the words of the chip, with a capital (the data's share of the range included) @@ -285,12 +285,12 @@ test("search: quick choices with the count typed, a year compared, and the rules assert.deepEqual(filtersOf(last2.choice.change().view, YEAR, RULE_TYPES), [{ field: YEAR, type: "relative", unit: "year", count: 2, not: false, blanks: "exclude" }]); // a range counted back from the latest record (2025): the search's choices count from it too const anchored = axisTopics({ view: setQuickRange(byYear, YEAR, { unit: "year", count: 1, anchor: "latest" }), zone: "rows", index: 0, field: YEAR, types, labels: MENU.en, locale: "en-US", encoded: data }); - const hit = searchHits(searchEntries(anchored, "last 3 years"), "last 3 years", "en-US")[0]; + const hit = searchHits(searchEntries(anchored, "last 3 years"), "last 3 years", "en-US").hits[0]; assert.equal(hit.text, chip({ unit: "year", count: 3, anchor: "latest" }).replace(/^l/, "L")); assert.deepEqual(filtersOf(hit.choice.change().view, YEAR, RULE_TYPES), [{ field: YEAR, type: "relative", unit: "year", count: 3, anchor: "latest", not: false, blanks: "exclude" }]); // a cyclic grouping has no quick choices to find const cyclic = axisTopics({ view: byCyclic, zone: "rows", index: 0, field: CYCLIC, types, labels: MENU.en, locale: "en-US", encoded: data }); - assert.equal(searchHits(searchEntries(cyclic, "last 2 years"), "last 2 years", "en-US").length, 0); + assert.equal(searchHits(searchEntries(cyclic, "last 2 years"), "last 2 years", "en-US").hits.length, 0); // a year grouping: no months assert.equal(hits("last 2 months").length, 0); const from = hits("from 2022")[0]; @@ -302,18 +302,18 @@ test("search: quick choices with the count typed, a year compared, and the rules assert.ok(hits("rule").some((e) => e.id === "open-filter-value")); // a date field: months too, and a year as its first or last day const raw = axisTopics({ view: norm({ rows: ["Released"] }), zone: "rows", index: 0, field: "Released", types, labels: MENU.en, locale: "en-US", encoded: data }); - const rawHits = (q) => searchHits(searchEntries(raw, q), q, "en-US"); + const rawHits = (q) => searchHits(searchEntries(raw, q), q, "en-US").hits; assert.equal(rawHits("last 6 months").length, 1); // a date field compares days: no year entry, whose chip would say a day ("from Jan 1, 2022") assert.equal(rawHits("up to 2022").length, 0); assert.equal(rawHits("from 2022").length, 0); // German words const de = axisTopics({ view: byYear, zone: "rows", index: 0, field: YEAR, types, labels: MENU.de, locale: "de-DE", encoded: data }); - assert.equal(searchHits(searchEntries(de, "ab 2022"), "ab 2022", "de-DE")[0].text, "Ab 2022"); - assert.ok(searchHits(searchEntries(de, "letzte 3 jahre"), "letzte 3 jahre", "de-DE")[0].text.startsWith("Letzte 3 Jahre (")); + assert.equal(searchHits(searchEntries(de, "ab 2022"), "ab 2022", "de-DE").hits[0].text, "Ab 2022"); + assert.ok(searchHits(searchEntries(de, "letzte 3 jahre"), "letzte 3 jahre", "de-DE").hits[0].text.startsWith("Letzte 3 Jahre (")); // a text field gets none of them; nothing typed, nothing made const text = axisTopics({ view: norm({ rows: ["Region"] }), zone: "rows", index: 0, field: "Region", types, labels: MENU.en, locale: "en-US", encoded: data }); - assert.equal(searchHits(searchEntries(text, "last 2 years"), "last 2 years", "en-US").length, 0); + assert.equal(searchHits(searchEntries(text, "last 2 years"), "last 2 years", "en-US").hits.length, 0); assert.equal(searchEntries(topics).some((e) => e.id.startsWith("quick-")), false); }); @@ -550,7 +550,7 @@ test("search: a quick choice found takes the place of the one set, keeps a range const view = norm(setRule(setQuickRange(byYear, YEAR, { unit: "year", count: 5, blanks: "include" }, null), YEAR, null, rule)); assert.equal(quickChoice(view, YEAR, fk).count, 5); const topics = axisTopics({ view, zone: "rows", index: 0, field: YEAR, types, labels: MENU.en, locale: "en-US", encoded: data }); - const hit = searchHits(searchEntries(topics, "last 3 years"), "last 3 years", "en-US")[0]; + const hit = searchHits(searchEntries(topics, "last 3 years"), "last 3 years", "en-US").hits[0]; const ranges = filtersOf(hit.choice.change().view, YEAR, ["relative"]); assert.deepEqual(ranges.map((f) => [f.count, f.not, f.blanks]), [[3, false, "include"], [1, true, "include"]]); }); @@ -594,7 +594,7 @@ test("Counted back from: every relative range of the field takes the reference, test("search: the rule on the name is found by its operators, \"does not begin with\" among them (review)", () => { for (const [L, locale, q] of [[MENU.en, "en-US", "does not begin"], [MENU.en, "en-US", "not end with"], [MENU.de, "de-DE", "beginnt nicht"]]) { const topics = axisTopics({ view: norm({ rows: ["Region"] }), zone: "rows", index: 0, field: "Region", types, labels: L, locale, encoded: data }); - assert.deepEqual(searchHits(searchEntries(topics, q), q, locale).map((e) => e.id), ["open-filter-text"], q); + assert.deepEqual(searchHits(searchEntries(topics, q), q, locale).hits.map((e) => e.id), ["open-filter-text"], q); } }); diff --git a/packages/pivotkit-react/test/menu-topics.test.js b/packages/pivotkit-react/test/menu-topics.test.js index a726d24c8..22e5d8fec 100644 --- a/packages/pivotkit-react/test/menu-topics.test.js +++ b/packages/pivotkit-react/test/menu-topics.test.js @@ -6,7 +6,7 @@ import { encode, normalize } from "pivotkit-core"; // the German first-load texts: pivotkit-react adds them as it loads (deferred.js) import "../src/deferred.js"; import { setItemFilter, setTopFilter, setValueFilter } from "../src/menu-ops.js"; -import { afterDelete, axisTopics, entryIds, formatLabel, moreTopics, rowFoldTexts, rowName, searchEntries, searchHits, SEARCH_HITS, searchHasMore, stepIndex, tableTopics, TOP_COUNTS, topText, typeAheadIndex, valueTopics } from "../src/menu-topics.js"; +import { afterDelete, axisTopics, entryIds, formatLabel, moreTopics, rowFoldTexts, rowName, searchEntries, searchHits, SEARCH_HITS, stepIndex, tableTopics, TOP_COUNTS, topText, typeAheadIndex, valueTopics } from "../src/menu-topics.js"; import { MENU } from "./helpers.js"; const data = encode([ @@ -200,7 +200,7 @@ test("the words of folding the groups of Rows: the fields' names, the plain word test("search: every choice of every level with its path, and the panels; all words must match; the start of a text first", () => { const view = norm({ rows: ["Region"], values: [units] }); const entries = searchEntries(valueTopics({ view, index: 0, types, labels: MENU.en, locale: "en-US" })); - const hit = (q) => searchHits(entries, q, "en-US").map((e) => `${e.text} | ${e.path}`); + const hit = (q) => searchHits(entries, q, "en-US").hits.map((e) => `${e.text} | ${e.path}`); assert.deepEqual(hit("currency"), ["Currency | Number format"]); assert.deepEqual(hit("compact"), ["Compact (1.2K) | Number format › More formats"]); // the path counts: "format" finds the formats, the words in any order @@ -208,16 +208,16 @@ test("search: every choice of every level with its path, and the panels; all wor assert.deepEqual(hit("name"), ["Name | "]); assert.deepEqual(hit(" "), []); assert.deepEqual(hit("nothing like this"), []); - assert.ok(searchHits(entries, "o", "en-US").length <= SEARCH_HITS); - assert.equal(searchHasMore(entries, "o", "en-US"), true); - assert.equal(searchHasMore(entries, "currency", "en-US"), false); - assert.equal(searchHasMore(entries, " ", "en-US"), false); + assert.ok(searchHits(entries, "o", "en-US").hits.length <= SEARCH_HITS); + assert.equal(searchHits(entries, "o", "en-US").hasMore, true); + assert.equal(searchHits(entries, "currency", "en-US").hasMore, false); + assert.equal(searchHits(entries, " ", "en-US").hasMore, false); // a field's: the Filter panel is an entry that opens it const field = searchEntries(axis(view)); // the Filter panel's own entries (its rules) are found by its title too // ("Filter by name" and "Filter by total" start with the words, the rules have them in their path) - assert.deepEqual(searchHits(field, "filt", "en-US").map((e) => [e.id, Boolean(e.choice)]), [["open-filter", false], ["open-filter-text", false], ["open-filter-value", false], ["open-filter-rules", false], ["move-filters", true]]); - assert.deepEqual(searchHits(field, "move col", "en-US").map((e) => e.id), ["move-cols"]); + assert.deepEqual(searchHits(field, "filt", "en-US").hits.map((e) => [e.id, Boolean(e.choice)]), [["open-filter", false], ["open-filter-text", false], ["open-filter-value", false], ["open-filter-rules", false], ["move-filters", true]]); + assert.deepEqual(searchHits(field, "move col", "en-US").hits.map((e) => e.id), ["move-cols"]); }); test("the keys of a menu: arrows around the ends, Home and End; type-ahead moves on with one letter, stays with more", () => { @@ -262,13 +262,13 @@ test("the Views menu's entries: ids by group, name and repeat; after a delete th test("search: the shares of Show as come first for percent and %; the conditions and Top 5 are entries; rename finds Name", () => { const view = norm({ rows: ["Region"], values: [units] }); const value = searchEntries(valueTopics({ view, index: 0, types, labels: MENU.en, locale: "en-US" })); - const first = (q) => searchHits(value, q, "en-US").map((e) => e.text); + const first = (q) => searchHits(value, q, "en-US").hits.map((e) => e.text); assert.equal(first("percent")[0], "% of grand total"); assert.ok(first("percent").includes("Percent"), "the format of that name is still found"); assert.equal(first("%")[0], "% of grand total"); assert.deepEqual(first("rename"), ["Name"]); const field = searchEntries(axis(view)); - const hits = (q) => searchHits(field, q, "en-US"); + const hits = (q) => searchHits(field, q, "en-US").hits; assert.deepEqual(hits("filter by name").map((e) => [e.id, e.focus]), [["open-filter-text", "conditions"]]); assert.ok(hits("filter by total").some((e) => e.id === "open-filter-value" && e.focus === "conditions")); // "rule" finds the rules, and opens the level on them From 3f45ed487e475c47ecd77f1da35dae77b3060945 Mon Sep 17 00:00:00 2001 From: harshita-jangra Date: Thu, 26 Nov 2026 14:59:40 +0530 Subject: [PATCH 3/3] Restore menu search documentation and formatting --- packages/pivotkit-react/src/levels.jsx | 23 +++++++++++----------- packages/pivotkit-react/src/menu-topics.js | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/pivotkit-react/src/levels.jsx b/packages/pivotkit-react/src/levels.jsx index 9995a4d9a..201e98304 100644 --- a/packages/pivotkit-react/src/levels.jsx +++ b/packages/pivotkit-react/src/levels.jsx @@ -466,17 +466,18 @@ function SearchHits({ hits, labels, onPick, onOpen, close, hasMore }) {

); } - return (<> - - {hits.map((h) => ( - (h.choice ? onPick(h.choice) : onOpen(h.topic.id, undefined, h.focus))} /> - ))} - - {hasMore ? ( -

- {fill(labels.searchMore, { count: SEARCH_HITS })} -

- ) : null} + return ( + <> + + {hits.map((h) => ( + (h.choice ? onPick(h.choice) : onOpen(h.topic.id, undefined, h.focus))} /> + ))} + + {hasMore ? ( +

+ {fill(labels.searchMore, { count: SEARCH_HITS })} +

+ ) : null} ); } diff --git a/packages/pivotkit-react/src/menu-topics.js b/packages/pivotkit-react/src/menu-topics.js index 06c9027be..ce012a70e 100644 --- a/packages/pivotkit-react/src/menu-topics.js +++ b/packages/pivotkit-react/src/menu-topics.js @@ -843,7 +843,7 @@ export const SEARCH_HITS = 8; /** * The entries every word of `query` is found in (its text or its path), at most SEARCH_HITS; those - * whose text starts with the query first, and whether more matches exist. + * whose text starts with the query first. * @param {SearchEntry[]} entries * @param {string} query * @param {string} [locale]