Skip to content

feat(popup-menu): add forceOrderMinScore to data-first node defs - #602

Merged
kianbazza merged 1 commit into
ship/data-first-search-honour-filter-and-let-forceorderfrom
ship/force-order-min-score
Oct 28, 2026
Merged

kianbazza merged 1 commit into
ship/data-first-search-honour-filter-and-let-forceorderfrom
ship/force-order-min-score

Conversation

@kianbazza

@kianbazza kianbazza commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

forceOrder is compared before score, so a row with forceOrder: -1 leads any search it matches at all, even weakly. In a command menu where the theme options Light, Dark and System carry forceOrder: -1, typing "sett" puts System (score 0.14, through its keywords) above Settle (0.99).

The new forceOrderMinScore on node defs keeps forceOrder for good matches only:

 getNodeForceOrder(def, score)
+  if def.forceOrderMinScore is set and score < def.forceOrderMinScore
+    return 0          // sorts by score, as if it had no forceOrder
   return def.forceOrder ?? 0

It's on every def that has forceOrder: items, link items, tree items, radio and checkbox items, submenus and subpages. Every data-first sort uses the same helper: ungrouped rows, the order inside groups, radio groups and checkbox groups, the order of those groups, and the items-before-branches buckets. forceScore, when set, is the score compared. A row below the minimum still shows.

{ kind: 'radio-item', value: 'System', keywords: ['Theme'], forceOrder: -1, forceOrderMinScore: 0.5 }
// "sys"  → System leads (0.99)
// "sett" → Settle (0.99), then System (0.14)

Evidence

  • Before: filterNodes for "sett" over Settle and System (forceOrder: -1) returns [System, Settle].
    After: with forceOrderMinScore: 0.5 it returns [Settle, System]. For "s", where both score 0.99, System still leads.
  • New tests in stateful-items.test.ts › forceOrderMinScore cover the preserve and flatten group behaviours, a strong match, the default, forceScore on either side of the minimum, a radio group, and a submenu trigger. Five of the eight fail when the minimum is ignored.
  • bun run check, bun run type-check, bun run test --filter @bazza-ui/react (1540 passed), bun run docs:type-gen.

Merge Danger

Door: two-way

Blast Radius: none

Opt-in prop. Without it, sorting doesn't change.

@kianbazza
kianbazza added this pull request to stack #603 October 28, 2026 00:07
@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ui-canary Ready Ready Preview Oct 28, 2026 12:08am UTC

Request Review

@linear-code

linear-code Bot commented Oct 28, 2026

Copy link
Copy Markdown

UI-657

@kianbazza
kianbazza marked this pull request as ready for review October 28, 2026 15:36
@kianbazza
kianbazza merged commit 8deecbb into canary Oct 28, 2026
5 checks passed

This branch was successfully deployed

1 active deployment
Preview – ui-canary — 483da748 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant