Skip to content

feat(multiselector): formatTriggerCount prop for custom count trigger text (proposal for #3348) - #3354

Merged
thedjpetersen merged 2 commits into
mainfrom
claude/feat/multiselector-format-trigger-count
Sep 19, 2026
Merged

thedjpetersen merged 2 commits into
mainfrom
claude/feat/multiselector-format-trigger-count

Conversation

@thedjpetersen

Copy link
Copy Markdown
Contributor

Draft — pending API sign-off on #3348. Issue-first per the AI-contribution guide; implements the arbitration winner so the shape can be reviewed against real code.

What

Adds formatTriggerCount?: (count: number) => string to MultiSelector.

  • In the trigger-content memo's 'count' branch, the text is now formatTriggerCount?.(count) ?? ${count} selected``.
  • Default behavior is unchanged; the prop applies only when triggerDisplay='count' (the default). labels and badges modes are untouched.
  • JSDoc on the prop with a singular/plural example; triggerDisplay docs updated to point at it.
  • MultiSelector.doc.mjs updated (props table, dense + zh translations, triggerDisplay description).
  • The MultiSelectorColumnVisibilitySelector CLI showcase block (already triggerDisplay="count" with a hidden label) now demonstrates the prop with "N columns shown".
  • Changeset: @astryxdesign/core + @astryxdesign/cli, patch (pre-1.0 patch-only).

Why

The 'count' trigger text was hard-coded ${count} selected. A builder using Astryx for an internal tool (Meridian) needed "3 spaces selected" with no visible label, found no prop, and rebuilt the control from Popover + CheckboxInput — the highest-cost failure mode for the system. renderOption already establishes function-prop customization on this exact component; the count text is presentation, not data.

API arbitration (from #3348, compact round, 2026-07-01 — naive sonnet generations + haiku hallucination probe):

Candidate Invented props Escape hatches Notes
formatTriggerCount fn 0 0 exact output; covers singular/plural + i18n
itemNoun string 0 0 can't cover singular/plural or i18n
triggerContent render-fn 0 0 widest surface

Testing

  • MultiSelector.test.tsx: 43 tests pass (40 existing + 3 new — custom formatter renders "2 spaces selected", default "1 selected" unchanged without the prop, formatter is ignored in labels mode).
  • @astryxdesign/core typecheck clean; eslint + prettier clean on changed files; pnpm check:repo (changesets, sync, package boundaries, demo media) passes.
  • Pre-existing, unrelated failure in derivedVarRegistry.test.ts reproduces on a clean tree (verified via stash).

Open questions

  • itemNoun runner-up: should a string convenience prop also exist for the 90% case (itemNoun="space" → "3 spaces selected"), layered on top of the formatter?
  • Should the formatter also receive the selected labels ((count, labels) => string), or is that labels mode's job?

… text

Adds an optional formatTriggerCount?: (count: number) => string prop to
MultiSelector. When triggerDisplay='count' (the default), the trigger text
is formatTriggerCount?.(count) ?? `${count} selected` — default behavior
unchanged; labels/badges modes untouched.

Implements the arbitration winner from #3348.

(pre-commit run manually: eslint + prettier on changed files, pnpm check:repo —
npx lint-staged unavailable offline)
@vercel

vercel Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 19, 2026 4:27am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Jul 2, 2026
* ```
* @default (count) => `${count} selected`
*/
formatTriggerCount?: (count: number) => string;

@cixzhang cixzhang Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internally, we have this prop

getButtonLabelFromValue
(?ReadonlyArray<TValue>) => string
Customize how we create the button label from values. Also used for providing an accessible label that won't be displayed on the screen. - Must return a non-empty string. - If you want to hide the button label, set isButtonLabelHidden. - By default, we render the value's label if there's only one, otherwise we show "# items".

It's a bit wordy and I don't really like that we called these "buttons" since they're really not buttons. I do think we need a better pattern.

@cixzhang cixzhang added area:cli needs:code-review High-risk change (new package/component/API) — needs human code review before merge and removed area:cli labels Jul 8, 2026
@github-actions github-actions Bot added needs:design-review Affects visuals — Design should review and removed needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Jul 12, 2026
…ctor-format-trigger-count

# Conflicts:
#	packages/core/src/MultiSelector/MultiSelector.doc.mjs
#	packages/core/src/MultiSelector/MultiSelector.test.tsx
#	packages/core/src/MultiSelector/MultiSelector.tsx
@thedjpetersen
thedjpetersen marked this pull request as ready for review September 19, 2026 04:22
@github-actions github-actions Bot removed the needs:design-review Affects visuals — Design should review label Sep 19, 2026
@thedjpetersen
thedjpetersen merged commit 7ccd6c8 into main Sep 19, 2026
28 of 30 checks passed
@github-actions
github-actions Bot deleted the claude/feat/multiselector-format-trigger-count branch September 19, 2026 06:20
thedjpetersen added a commit that referenced this pull request Sep 19, 2026

This branch was successfully deployed

1 active deployment
Preview — d3a77924 Deployed Sep 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants