-
Notifications
You must be signed in to change notification settings - Fork 142
Add Card Counts to Tag #2828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Card Counts to Tag #2828
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2828 +/- ##
==========================================
- Coverage 72.20% 72.09% -0.11%
==========================================
Files 134 134
Lines 7461 7411 -50
Branches 1648 1645 -3
==========================================
- Hits 5387 5343 -44
+ Misses 1946 1940 -6
Partials 128 128 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds card count indicators to tags in the CardStack component to help users understand how many cards are associated with each tag. The implementation modifies the tag mapping logic to track counts and displays them in badges alongside the existing tag selection checkmarks.
Changes:
- Modified
updateTagMapping()function to calculate and store the number of cards associated with each tag - Added a count badge display in the tag UI, positioned between the tag name and the selection checkmark
- Added comprehensive test coverage for the tag counting feature including edge cases
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/vue-components/src/cardstack/CardStack.vue | Added count property to tag mappings, updated initialization logic to track tag occurrences, added count badge UI element, and adjusted CSS spacing for tag indicators |
| packages/vue-components/src/tests/snapshots/CardStack.spec.js.snap | Updated snapshot to reflect the new count badge in tag display |
| packages/vue-components/src/tests/CardStack.spec.js | Added four new test cases covering count initialization for custom tags, count increments for duplicate tags, count badge display, and badge ordering |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Can consider adding a boolean flag to set as false or true to disable the count per tag (default: show) |
gerteck
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/vue-components/src/__tests__/__snapshots__/CardStack.spec.js.snap
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
|
@yihao03 Also update the PR description with the latest UI screenshots. |
|
Hi @yihao03, great work on this feature! As we discussed in class, perhaps it would be more intuitive for the user to have the count be reactive and update based on the cards currently displayed in the cardstack. |
Move components from data() to setup() and use reactive object to make use of Vue 3 reactivity=
|
good idea @MoshiMoshiMochi ! It has been implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| tagCounts() { | ||
| const counts = {}; | ||
| this.cardStackRef.children.forEach((child) => { | ||
| if (child.disabled) return; | ||
| const searchTerms = this.cardStackRef.searchTerms || []; | ||
| const searchTarget = (child.computeTags.join(' ') | ||
| + child.keywords + child.headerText).toLowerCase(); |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tagCounts builds counts as a plain object with user-controlled tag names as keys. Tags like __proto__ / constructor can cause prototype pollution or unexpected lookups, and falsy inherited keys can affect tagCounts[key] || 0. Use a Map or Object.create(null) for counts (and adjust the template lookup accordingly) to avoid prototype inheritance issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In JavaScript, plain objects {} inherit properties from the global Object.prototype.
- Bug: If a user-provided tag is named "toString" or "hasOwnProperty", your code counts[tag] = (counts[tag] || 0) + 1 will fail. It will try to add 1 to a function, resulting in NaN.
Means if use {} directly, using tagnames like valueOf constructor etc will break, use a map instead
const counts = new Map();
and also change the methods to .get() and .set()


What is the purpose of this pull request?
Overview of changes:
Add card counts to tag. Updated the
updateTagMapping()function inCardStack.vueto calculatethe number of cards associated with each tag and store this information in the
tagMapping.Displays the count between the tag text and the tickbox in the tags. Closes #2808
Anything you'd like to highlight/discuss:
How should I make it look prettier or is this fine?
Testing instructions:
Run
markbind serve -dto serve the docs and checkout the cardstack documentation pages.Proposed commit message: (wrap lines at 72 characters)
Add card counts to tags in CardStack component
Checklist: ☑️
Reviewer checklist:
Indicate the SEMVER impact of the PR:
At the end of the review, please label the PR with the appropriate label:
r.Major,r.Minor,r.Patch.Breaking change release note preparation (if applicable):