Skip to content

fix(Tokenizer): block token changes while disabled - #8408

Merged
cixzhang merged 1 commit into
meta:mainfrom
korkt-kim:korkt-kim/fix-tokenizer-disabled
Oct 25, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
korkt-kim:korkt-kim/fix-tokenizer-disabled

Conversation

@korkt-kim

Copy link
Copy Markdown
Contributor

User impact

A disabled Tokenizer with a reason remains keyboard-focusable. With an existing token and an empty input, pressing Backspace currently calls onChange and removes that token in a controlled form. Someone looking at a disabled field can therefore still change its selected members.

Problem and solution fit

Backspace and the removal callback supplied to renderToken share handleRemove, which does not check isDisabled. An already-open search result can also reach the unguarded add/create callback after the field becomes disabled. Blocking input editing alone does not protect those commit paths.

The fix checks isDisabled at the shared add, remove, and clear boundaries, before callbacks, token announcements, or removal refocus. Including it in the callback dependencies keeps the check current when availability changes. Enabled commits keep the same metadata and focus behavior.

Disabled hidden form inputs are omitted instead of rendered with native disabled, preserving their existing exclusion from form submission without emitting that attribute.

Expected behavior and authority

Current AST-085 FR2 requires disabled controls to block value changes and callbacks. Backspace, supplied removal callbacks, and an already-open result are paths to the same token change.

FR1 and FR3 prohibit native disabled and require disabled values to stay out of form submission. The existing form test checks both carrier omission and validity.

Smallest restoration

Local guards and callback dependencies in Tokenizer.tsx, focused coverage in the existing test file, and a patch changeset. The typing/removal test covers Backspace and the supplied custom-token callback; one added test covers a result that was open before disablement. No new test file, parameterized matrix, prop, story, styling, or layout change.

Evidence

  • Before: focus the disabled Members input with Alice selected, leave the input empty, then press Backspace. Alice disappears and onChange runs once despite the disabled state.
  • After: the same action leaves Alice selected, does not call onChange, and keeps input focus. The disabled reason remains associated with the focused combobox.
  • Representative unchanged path: reset the fixture to enabled with Alice selected, then press Backspace. Alice is removed, one callback runs, and input focus remains in both versions.
  • Regression proof: loading only Tokenizer.tsx from base d70e0ec013 makes the three affected regression cases fail at disabled callback or hidden-carrier assertions. The current implementation passes all 91 focused tests. No working-tree source swap was used.

Both recordings use Playwright Chromium 149 on macOS at 1000 × 640 with the same controlled fixture, callback, and Neutral theme. AS-IS loads the base Tokenizer module; TO-BE loads the committed implementation. Captions and pointer/key markers are recording-only. No recording assets or fixture are added to the implementation branch.

AS-IS

as-is.mp4

TO-BE

to-be.mp4

Scope

  • One defect is addressed: disabled Tokenizer-owned paths can still commit token changes.
  • Enabled changes, callback metadata, and removal focus behavior are preserved.
  • No new public API, visual representation, or unrelated cleanup is included.
  • Public text and recordings contain no internal Meta context.

BaseTypeahead's popup lifecycle and no-reason disabled-input focus behavior are unchanged; this change guards Tokenizer's value commits rather than claiming full wrapper conformance. Caller-rendered token elements still own their attributes.

Testing

  • pnpm build and pnpm -F @astryxdesign/core typecheck — passed.
  • pnpm exec vitest run --project ui packages/core/src/Tokenizer/ --maxWorkers=1 — 91 passed.
  • Strict ESLint on both changed TSX files — passed with 0 errors and one existing unused-variable warning.
  • Chromium before/after assertions — disabled Backspace, unchanged enabled removal, focus continuity, and focused-input AX name/state/reason verified.
  • Base-source regression-failure proof — three expected failures; current-source regressions pass.
  • Prettier, repository checks, check:changesets, git diff --check, and commit hooks — passed.

The broader repository test run stops at the pre-existing CLI doctor-notice assertion in packages/cli/test/global-local.test.mjs:407 (notice[1] is undefined). pnpm lint:strict completed repository checks but reached the 10-minute limit during workspace-wide ESLint; strict lint of the changed files passes.

@vercel

vercel Bot commented Oct 25, 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 Oct 25, 2026 2:59pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 25, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Oct 25, 2026
@astracat-bot

astracat-bot Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 25, 2026, 3:16 PM UTC

@astracat-bot astracat-bot Bot left a comment

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.

No blocking issues found. Returning early from handleAdd, handleRemove and handleClearAll while isDisabled stops Backspace, a supplied renderToken removal and an already-open result from changing a disabled Tokenizer, as spec:AST-085 FR2 requires, and omitting the disabled hidden inputs meets FR1 and FR3. The new and extended tests fail against the previous implementation and pass with this change, and enabled removal is unchanged. Nothing more is needed here; a menu that is already open when the field becomes disabled still stays open, which is BaseTypeahead popup behavior outside this change.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

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.

No blocking issues found: returning early from handleAdd, handleRemove and handleClearAll while isDisabled stops Backspace, a supplied renderToken removal and an already-open result from changing a disabled Tokenizer, as spec:AST-085 FR2 requires, and omitting the disabled hidden inputs meets FR1 and FR3. The changed tests fail against the previous implementation and pass with this change, and enabled removal behaves as before. Nothing more is needed here; a menu that stays open when the field becomes disabled, and ArrowDown opening one while disabled, are BaseTypeahead behaviors outside this change.

[Automated review]

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Tokenizer (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Entry File (ESM) 331B 331B 0B
Lines of Code 872 871 -
Complexity Very High Very High (124) -

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/PowerSearch 144.1KB 144.1KB +5B 18.1KB 18.1KB 0B
core/Tokenizer 61.2KB 61.2KB +9B 11.4KB 11.4KB 0B

Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included.

Bundle Size Summary

Gzip figures measure each package's entry file, not the code an import pulls in.

Package Entry (ESM) Entry gzip before Entry gzip after Delta
@astryxdesign/core 4.9KB 1.2KB 1.2KB 0B
Package stylesheet Gzip before Gzip after Delta
@astryxdesign/core 33.7KB 33.7KB 0B

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

Tokenizer - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/26 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Visual Regression

48 of 502 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
RichTextEditor Markdown parity: side by side probe dark 556,900
RichTextEditor Markdown parity: side by side probe light 538,816
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
AppShell With Mobile Nav probe light 217,010
AppShell With Mobile Nav probe dark 216,960
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
AppShell Playground neutral dark 65,198
AppShell Playground neutral light 63,788
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232

and 28 more.


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

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Oct 25, 2026
@cixzhang
cixzhang merged commit cc95dd0 into meta:main Oct 25, 2026
68 checks passed
@github-actions
github-actions Bot deleted the korkt-kim/fix-tokenizer-disabled branch October 26, 2026 11:39

This branch was successfully deployed

1 active deployment
Preview — 3d51a575 Deployed Oct 25, 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. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants