feat: add TagGroup component#2684
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new TagGroup UI: Root (v-model, form integration), Item (selection/keyboard removal), ItemText, ItemDelete, barrel exports, plugin wiring, docs/demos, and tests verifying accessibility, pointer/keyboard removal, and disabled behavior. ChangesTagGroup Component Implementation
Sequence Diagram(s)sequenceDiagram
participant User
participant TagGroupRoot
participant TagGroupItem
participant TagGroupItemDelete
participant Model
User->>TagGroupRoot: focus/interact with list
TagGroupRoot->>TagGroupItem: render items from modelValue
User->>TagGroupItemDelete: click delete or press Delete/Backspace on focused item
TagGroupItemDelete->>TagGroupItem: call remove()
TagGroupItem->>TagGroupRoot: invoke removeTag(value)
TagGroupRoot->>Model: update modelValue (filter out value) and emit update:modelValue
TagGroupRoot->>TagGroupItem: re-render without removed item
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/core/src/TagGroup/TagGroup.test.ts (1)
44-49: ⚡ Quick winConsider verifying the
removeTagevent emission.The test correctly validates that clicking the delete button updates the model and DOM. However, it doesn't assert that the
removeTagevent is emitted with the correct payload. Adding an event assertion would provide more complete coverage of the component contract.✅ Example event assertion
You can add an event listener before the click and assert it was called:
it('should remove a tag from model value when delete button is clicked', async () => { + const removeSpy = vi.fn() + wrapper.vm.$on('removeTag', removeSpy) + await wrapper.findAll('button[aria-label^="Remove"]')[1].trigger('click') expect(wrapper.vm.tags).toEqual(['Vue', 'Accessibility']) expect(wrapper.findAll('[role="listitem"]').map(item => item.text())).toEqual(['Vue', 'Accessibility']) + expect(removeSpy).toHaveBeenCalledWith('Reka UI') })🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/core/src/TagGroup/TagGroup.test.ts` around lines 44 - 49, After the click assertion, also assert the component emitted the removeTag event with the expected payload: call wrapper.emitted() and verify there is a 'removeTag' entry and that its first emission payload matches the removed tag (or index) — e.g. check wrapper.emitted('removeTag')[0] equals the expected value corresponding to the button you clicked (use the same target used in the test: the second remove button from wrapper.findAll('button[aria-label^="Remove"]')[1]).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/TagGroup/TagGroupItemDelete.vue`:
- Around line 24-35: The click handler is directly bound to itemContext.remove
so clicks still remove tags even when the component is disabled (especially for
non-button/asChild elements); update TagGroupItemDelete to use an internal click
handler (e.g. onClick) instead of binding itemContext.remove directly, have that
handler read the computed disabled (from disabled or props.disabled) and return
early when disabled is true, otherwise call itemContext.remove; then change the
template `@click.stop` to call the new handler (e.g. `@click.stop`="onClick") so
disabled state properly guards the delete action.
---
Nitpick comments:
In `@packages/core/src/TagGroup/TagGroup.test.ts`:
- Around line 44-49: After the click assertion, also assert the component
emitted the removeTag event with the expected payload: call wrapper.emitted()
and verify there is a 'removeTag' entry and that its first emission payload
matches the removed tag (or index) — e.g. check wrapper.emitted('removeTag')[0]
equals the expected value corresponding to the button you clicked (use the same
target used in the test: the second remove button from
wrapper.findAll('button[aria-label^="Remove"]')[1]).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 478aea6f-24df-4360-a66b-ec632bb15664
📒 Files selected for processing (9)
packages/core/constant/components.tspackages/core/src/TagGroup/TagGroup.test.tspackages/core/src/TagGroup/TagGroupItem.vuepackages/core/src/TagGroup/TagGroupItemDelete.vuepackages/core/src/TagGroup/TagGroupItemText.vuepackages/core/src/TagGroup/TagGroupRoot.vuepackages/core/src/TagGroup/index.tspackages/core/src/index.tspackages/plugins/src/namespaced/index.ts
🔗 Linked issue
Closes #2525
❓ Type of change
📚 Description
Adds a new
TagGroupprimitive for rendering removable selected values, useful for filters and multiselect selections.This includes:
TagGroupRootwith controlled/uncontrolled model support and form integrationTagGroupItem,TagGroupItemText, andTagGroupItemDeleteDeleteandBackspace📸 Screenshots (if appropriate)
N/A
📝 Checklist
Summary by CodeRabbit