Repository navigation
fix(Tokenizer): suppress Create option for already-selected labels (#6366) - #6369
onlyysaurabh wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
The exact-head preview is not available yet. Generated by PR Enrichment workflow | View current CI run |
There was a problem hiding this comment.
This PR can be closed: the same fix for #6366 already landed on main in #6367 and shipped in 0.7.1, and this branch now conflicts with main in Tokenizer.tsx and Tokenizer.test.tsx. Rebasing would only add a second copy of the same label check and a duplicate changeset. The one piece main lacks is a test that types a selected label in another case (alice for Alice); if you want to keep it, it fits as a small test-only PR against current main. Thanks for the clear root-cause write-up.
[Automated review]
|
Closing as superseded by #6367. Posted by Cindy's agent on her behalf. |
Summary & User Impact
Fixes #6366.
In
Tokenizer, typing the label of an already-selected item whereid !== label(e.g.{ id: 'u1', label: 'Alice' }) offered a redundantCreate "Alice"option in the dropdown. Selecting it appended a duplicate token under a synthetic id ({ id: 'Alice', label: 'Alice' }).This PR suppresses the
Createsuggestion case-insensitively for any label already present invalue, and guards the commit path against creating duplicate tokens.Root Cause
createEntriesandhandleAddonly checkedselectedIds.has(trimmed)/selectedIds.has(createdValue).id !== label, comparing the typed label string against selected IDs evaluated tofalse.filteredSourcepre-filtersresultsby selected IDs beforecreateEntriesruns, soresults.some(...)never saw the selected items either.Changes
packages/core/src/Tokenizer/Tokenizer.tsx:createEntries: addedvalue.some(item => item.label.toLowerCase() === queryLower)to thealreadyExistsguard; addedvalueto the dependency array.handleAdd: addedvalue.some(v => v.label.toLowerCase() === createdValueLower)to the creatable branch as defense-in-depth on commit.packages/core/src/Tokenizer/Tokenizer.test.tsx:suppresses Create case-insensitively for already-selected labelcoveringid !== labeland case-insensitivity.@astryxdesign/corepatch changeset (.changeset/tokenizer-suppress-create-option-for-already-sel-p98g.md).Verification & Testing
pnpm vitest run packages/core/src/Tokenizer/Tokenizer.test.tsx(74/74 passed)pnpm vitest run packages/core/src/Typeahead/Typeahead.test.tsx(81/81 passed)pnpm eslint packages/core/src/Tokenizer(0 errors)pnpm check:repo(all 14 repository validation gates passed)