Adds optional parameter for maximum elements displayed when wt-cms-element="empty"#69
Conversation
…element="empty" flag is set
There was a problem hiding this comment.
Pull request overview
This PR adds a configurable empty-state threshold feature to CMSFilter, allowing the empty block to appear when there are N or fewer filtered results rather than only when there are zero results. The PR also establishes comprehensive test infrastructure with Jest and GitHub Actions CI/CD.
Changes:
- Added
wt-cmsfilter-empty-maxattribute to CMSFilter for configurable empty-state display threshold - Implemented full test suite with Jest for 11 modules (CMSFilter, ShareLink, ReadTime, Marquee, FormatNumbers, FormCheck, CountUp, CopyToClipboard, CookieConsent, CMSSelect)
- Added GitHub Actions workflows for automated testing and contributor updates
- Enhanced ShareLink module with better error handling, clipboard fallback, and custom event dispatching
- Added CommonJS exports to all modules for test compatibility
Reviewed changes
Copilot reviewed 18 out of 30 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| Dist/WebflowOnly/CMSFilter.js | Core feature: added emptyMaxCount property with parsing logic; updated ToggleEmptyState to compare filteredItems.length <= emptyMaxCount |
| docs/WebflowOnly/CMSFilter.md | Documented new wt-cmsfilter-empty-max attribute with usage examples |
| tests/CMSFilter.test.js | Added comprehensive tests for empty-max threshold, default behavior, and standalone empty element |
| tests/*.test.js (10 files) | Complete test coverage for ShareLink, ReadTime, Marquee, FormatNumbers, FormCheck, CountUp, CopyToClipboard, CookieConsent, CMSSelect |
| Dist/Functional/ShareLink.js | Major enhancements: error handling, clipboard fallback, custom events, template caching, security attributes |
| Dist/Functional/Marquee.js | Added infinite loop protection in fillContainer method |
| Dist/Functional/CopyToClipboard.js | Fixed null check for ctcTarget |
| Dist/Functional/*.js (7 files) | Added CommonJS exports for test compatibility |
| Dist/WebflowOnly/CMSSelect.js | Added CommonJS exports for test compatibility |
| package.json | Added Jest configuration and test script |
| jest.setup.js | Global Jest setup with polyfills for jsdom |
| .github/workflows/tests.yml | Automated test execution with coverage reporting |
| .github/workflows/update-contributors.yml | Automated contributor list updates |
| README.md | Updated badge (28k→30k hits), added contributors section, updated project link |
| CONTRIBUTING.md | Added contributor documentation |
| docs/WebflowOnly/CMSSelect.md | Added programmatic usage documentation |
| .gitignore | Added node_modules and .vscode exclusions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot code review[agent] |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 4 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
New Feature: Configurable Empty State Threshold for CMSFilter
Description
This feature adds configurable empty-state behaviour to CMSFilter so the empty block appears when there are N or fewer filtered results, rather than only when there are zero. This gives builders more flexibility for “low results” UX states.
Script Details
wt-cmsfilter-empty-max="n"is set on the element withwt-cmsfilter-element="empty", the empty block is shown when the filtered result count is≤ n. Missing/invalid values default to0(existing behaviour).Changes Made
wt-cmsfilter-empty-maxin the CMSFilter constructor.emptyMaxCountinternal property with default 0.filteredItems.length <= emptyMaxCount.wt-cmsfilter-empty-maxis set,wt-cmsfilter-element="empty"behaviour by itself,wt-cmsfilter-empty-maxis omitted.Features
wt-cmsfilter-empty-max="n"on the empty element.This PR closes NONE
DEMO
Checklist
developbranch.Additional Notes
Add any extra details or comments for reviewers.