fix(editor): single-letter tags in select/multi-select table cell#14808
fix(editor): single-letter tags in select/multi-select table cell#14808darkskygit merged 3 commits intotoeverything:canaryfrom
Conversation
📝 WalkthroughWalkthroughThis PR fixes a bug where typing a character in multi-select/select fields creates a new option instead of filtering existing ones. The solution introduces tag draft management: character input is now captured and passed as initial draft text to the tag selection popup, enabling search/filter behavior instead of immediate option creation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
blocksuite/affine/data-view/src/__tests__/hotkeys.unit.spec.ts (1)
99-132: Nice coverage addition; consider assertingpreventDefaultin tag-column cases too.You already verify
preventDefaultin the normal char-start tests. Adding it in these new parameterized tag-column tests would lock behavior parity and prevent regressions.✅ Suggested test strengthening
logic.keyDown({ get: () => ({ raw: evt }) }); expect(cell.column.valueSetFromString).not.toHaveBeenCalled(); expect(setTagDraft).toHaveBeenCalledWith('C'); expect(selectionController.selection.isEditing).toBe(true); + expect(evt.preventDefault).toHaveBeenCalled();logic.keyDown({ get: () => ({ raw: evt }) }); expect(cell.column$.value.valueSetFromString).not.toHaveBeenCalled(); expect(setTagDraft).toHaveBeenCalledWith('C'); expect(selectionController.selection.isEditing).toBe(true); + expect(evt.preventDefault).toHaveBeenCalled();Also applies to: 171-206
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@blocksuite/affine/data-view/src/__tests__/hotkeys.unit.spec.ts` around lines 99 - 132, The new parameterized test for tag columns currently omits asserting that the keyboard event's preventDefault() was called; update the test in hotkeys.unit.spec.ts (the case using TableHotkeysController, selectionController.getCellContainer returning cell with setTagDraft, and logic.keyDown({ get: () => ({ raw: evt }) })) to also expect evt.preventDefault toHaveBeenCalled(), mirroring the normal char-start tests and ensuring preventDefault behavior is locked for tag-column flows where setTagDraft is used.blocksuite/affine/data-view/src/view-presets/table/pc/cell.ts (1)
49-59: Optional: extract shared tag-draft host behavior to avoid drift.This implementation is mirrored in
blocksuite/affine/data-view/src/view-presets/table/pc-virtual/row/cell.ts(Line 185-195). Consider centralizing this tiny behavior (mixin/helper/interface utility) so both hosts stay consistent as the draft lifecycle evolves.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@blocksuite/affine/data-view/src/view-presets/table/pc/cell.ts` around lines 49 - 59, The tag-draft lifecycle (_tagDraft, setTagDraft, consumeTagDraft) is duplicated between cell.ts and pc-virtual/row/cell.ts; extract this into a shared utility (e.g., a TagDraftHost interface plus a TagDraftMixin or helper functions) and replace the per-file fields/methods with calls to that shared implementation so both hosts delegate to the same logic; ensure the shared API exposes setTagDraft(value: string), consumeTagDraft(): string | undefined and an internal storage name consistent with _tagDraft to avoid behavioral drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@blocksuite/affine/data-view/src/__tests__/hotkeys.unit.spec.ts`:
- Around line 99-132: The new parameterized test for tag columns currently omits
asserting that the keyboard event's preventDefault() was called; update the test
in hotkeys.unit.spec.ts (the case using TableHotkeysController,
selectionController.getCellContainer returning cell with setTagDraft, and
logic.keyDown({ get: () => ({ raw: evt }) })) to also expect evt.preventDefault
toHaveBeenCalled(), mirroring the normal char-start tests and ensuring
preventDefault behavior is locked for tag-column flows where setTagDraft is
used.
In `@blocksuite/affine/data-view/src/view-presets/table/pc/cell.ts`:
- Around line 49-59: The tag-draft lifecycle (_tagDraft, setTagDraft,
consumeTagDraft) is duplicated between cell.ts and pc-virtual/row/cell.ts;
extract this into a shared utility (e.g., a TagDraftHost interface plus a
TagDraftMixin or helper functions) and replace the per-file fields/methods with
calls to that shared implementation so both hosts delegate to the same logic;
ensure the shared API exposes setTagDraft(value: string), consumeTagDraft():
string | undefined and an internal storage name consistent with _tagDraft to
avoid behavioral drift.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5a25c76e-9738-43ec-8111-65097dde75dc
📒 Files selected for processing (7)
blocksuite/affine/data-view/src/__tests__/hotkeys.unit.spec.tsblocksuite/affine/data-view/src/core/component/tags/multi-tag-select.tsblocksuite/affine/data-view/src/property-presets/multi-select/cell-renderer.tsblocksuite/affine/data-view/src/property-presets/select/cell-renderer.tsblocksuite/affine/data-view/src/view-presets/table/pc-virtual/row/cell.tsblocksuite/affine/data-view/src/view-presets/table/pc/cell.tsblocksuite/affine/data-view/src/view-presets/table/utils.ts
|
Hi @darkskygit, would appreciate your review on this when you have a moment, as it's a highly-requested fix. Thanks! |
3403237 to
78a9942
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #14808 +/- ##
==========================================
+ Coverage 47.43% 57.36% +9.92%
==========================================
Files 3162 3166 +4
Lines 171118 172217 +1099
Branches 22694 25340 +2646
==========================================
+ Hits 81176 98787 +17611
+ Misses 86506 69964 -16542
- Partials 3436 3466 +30
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary of Changes
Resolves #14715 and #14280.
When a user types into a Select/Multi-Select table cell to create/choose a tag, that character is stashed on the cell container (setTagDraft) instead of going through valueSetFromString. Opening the tag picker reads it via consumeTagDraftFromTableCellHost.
Verification
Screen.Recording.2026-04-08.at.4.35.06.PM.mov
Summary by CodeRabbit
New Features
Tests