Repository navigation
fix(Tokenizer): block token changes while disabled - #8408
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
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]
bdabf24 to
3d51a57
Compare
There was a problem hiding this comment.
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]
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsTokenizer (@astryxdesign/core) · View in Storybook
Component Size
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 SummaryGzip figures measure each package's entry file, not the code an import pulls in.
Accessibility AuditStatus: 1 accessibility violation(s) found — 1 serious. Tokenizer - 1 issue(s)
Visual Regression48 of 502 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 28 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
User impact
A disabled Tokenizer with a reason remains keyboard-focusable. With an existing token and an empty input, pressing Backspace currently calls
onChangeand 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
renderTokensharehandleRemove, which does not checkisDisabled. 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
isDisabledat 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
disabledand 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
onChangeruns once despite the disabled state.onChange, and keeps input focus. The disabled reason remains associated with the focused combobox.Tokenizer.tsxfrom based70e0ec013makes 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
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 buildandpnpm -F @astryxdesign/core typecheck— passed.pnpm exec vitest run --project ui packages/core/src/Tokenizer/ --maxWorkers=1— 91 passed.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:strictcompleted repository checks but reached the 10-minute limit during workspace-wide ESLint; strict lint of the changed files passes.