Skip to content

Adds optional parameter for maximum elements displayed when wt-cms-element="empty"#69

Merged
JorchCortez merged 2 commits intoTheCodeRaccoons:mainfrom
matthewcsimpson:feature/cms-filter-optional-max-elements
Feb 26, 2026
Merged

Adds optional parameter for maximum elements displayed when wt-cms-element="empty"#69
JorchCortez merged 2 commits intoTheCodeRaccoons:mainfrom
matthewcsimpson:feature/cms-filter-optional-max-elements

Conversation

@matthewcsimpson
Copy link
Contributor

@matthewcsimpson matthewcsimpson commented Feb 25, 2026

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

  • Script Name: CMSFilter
  • Purpose of Update: Enable more flexible empty-state display behaviour for Webflow CMS filtering.
  • New Behaviour: If wt-cmsfilter-empty-max="n" is set on the element with wt-cmsfilter-element="empty", the empty block is shown when the filtered result count is ≤ n. Missing/invalid values default to 0 (existing behaviour).

Changes Made

  • Added parsing of wt-cmsfilter-empty-max in the CMSFilter constructor.
  • Added emptyMaxCount internal property with default 0.
  • Updated empty-state toggle logic to compare filteredItems.length <= emptyMaxCount.
  • Updated CMSFilter docs to include the new optional attribute and behaviour details.
  • Added tests for:
    • empty threshold when wt-cmsfilter-empty-max is set,
    • wt-cmsfilter-element="empty" behaviour by itself,
    • default behaviour when wt-cmsfilter-empty-max is omitted.

Features

  • Configurable Empty Threshold
    • Adds wt-cmsfilter-empty-max="n" on the empty element.
    • Lets teams display helper messaging earlier (e.g., “Only a few results found”).
  • Backwards Compatible
    • Default remains 0, so existing implementations continue to work unchanged.
  • Improved Test Coverage
    • Covers explicit threshold, missing attribute default, and standalone empty element behavior.

This PR closes NONE

DEMO

Checklist

  • Feature has been tested locally with all relevant use cases.
  • Documentation has been updated (if necessary).
  • PR does not match another non-stale PR currently opened
  • PR name matches the format [ feature ]: Feature Name (versions separated by comma). More details here
  • PR's base is the develop branch.
  • Your Feature matches the standards laid out here

Additional Notes

Add any extra details or comments for reviewers.

Copilot AI review requested due to automatic review settings February 25, 2026 21:03
Copy link
Contributor

Copilot AI left a 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 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-max attribute 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.

@JorchCortez JorchCortez changed the base branch from Develop to main February 25, 2026 21:24
@matthewcsimpson
Copy link
Contributor Author

@copilot code review[agent]

Copy link
Contributor

Copilot AI left a 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 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.

@JorchCortez JorchCortez merged commit e6efa86 into TheCodeRaccoons:main Feb 26, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants