Skip to content

[CDX-418] Feature: Add componentOverrides to FilterGroup#226

Merged
esezen merged 13 commits intomainfrom
cdx-418-plp-ui-feature-add-componentoverrides-to-filtergroup
Apr 9, 2026
Merged

[CDX-418] Feature: Add componentOverrides to FilterGroup#226
esezen merged 13 commits intomainfrom
cdx-418-plp-ui-feature-add-componentoverrides-to-filtergroup

Conversation

@quiteeasy
Copy link
Copy Markdown
Contributor

@quiteeasy quiteeasy commented Mar 24, 2026

Pull Request Checklist

Before you submit a pull request, please make sure you have to following:

  • I have added or updated TypeScript types for my changes, ensuring they are compatible with the existing codebase.
  • I have added JSDoc comments to my TypeScript definitions for improved documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added any necessary documentation (if appropriate).
  • I have made sure my PR is up-to-date with the main branch.

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no API changes)
  • Documentation content changes
  • TypeScript type definitions update
  • Other... Please describe:

Copilot AI review requested due to automatic review settings March 24, 2026 18:53
constructor-claude-bedrock[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
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

Adds a componentOverrides / filterGroupOverrides API to enable consumer customization of FilterGroup subcomponents (and the whole group) via render-props or static JSX, with accompanying Storybook examples and tests.

Changes:

  • Introduces new override types (FilterGroupOverrides, FilterGroupRenderProps, etc.) in src/types.ts.
  • Wires filterGroupOverrides through Filters and CioPlpGrid into FilterGroup as componentOverrides.
  • Adds Storybook stories and Jest tests validating override behavior (root/header/optionsList/rangeSlider).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/types.ts Adds new public types for FilterGroup overrides and render-props payload.
src/components/Filters/Filters.tsx Adds filterGroupOverrides prop and passes to each FilterGroup.
src/components/Filters/FilterGroup.tsx Wraps default subtrees with RenderPropsWrapper to support slot overrides.
src/components/CioPlpGrid/CioPlpGrid.tsx Extends filterConfigs to include filterGroupOverrides and forwards configs to Filters.
src/index.ts Exports FilterGroupProps (types are also re-exported via export * from './types').
src/stories/components/Filters/Filters.stories.tsx Adds examples demonstrating each override slot.
src/stories/components/CioPlpGrid/CioPlpGrid.stories.tsx Adds an example demonstrating overrides via filterConfigs.
spec/components/Filters/Filters.test.jsx Adds integration tests for Filters.filterGroupOverrides.
spec/components/Filters/FilterGroup.test.jsx Adds unit tests for FilterGroup.componentOverrides.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/types.ts Outdated
Comment thread src/types.ts
Comment thread src/types.ts Outdated
Comment thread src/components/Filters/FilterGroup.tsx
constructor-claude-bedrock[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@esezen esezen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great, thanks for working on this!

Comment thread src/types.ts Outdated
Comment thread src/components/CioPlpGrid/CioPlpGrid.tsx Outdated
Comment thread spec/components/Filters/FilterGroup.test.jsx Outdated
constructor-claude-bedrock[bot]

This comment was marked as outdated.

Comment thread src/components/Filters/FilterGroup.tsx Outdated
Comment thread src/components/CioPlpGrid/CioPlpGrid.tsx Outdated
Comment thread src/stories/components/CioPlpGrid/CioPlpGrid.stories.tsx Outdated
constructor-claude-bedrock[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
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 10 out of 11 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
Comment on lines 114 to 119
"typescript": "^4.9.4",
"vite": "^6.3.5",
"vite-plugin-css-injected-by-js": "^3.1.0",
"webpack": "^5.94.0"
"webpack": "^5.94.0",
"@constructor-io/constructorio-ui-components": "^1.3.2"
},
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@constructor-io/constructorio-ui-components is added under devDependencies, but the library’s published .d.ts now references types from this package (e.g., ComponentOverrideProps, IncludeComponentOverrides). Consumers won’t have this installed when they depend on this package, which will break TypeScript type resolution. Move this to peerDependencies (and optionally also keep it in devDependencies for local development), or remove the external type reference by defining equivalent types locally.

Copilot uses AI. Check for mistakes.
Comment thread src/types.ts

/**
* Render props passed to every FilterGroup override function.
* Provides the full state needed to rebuild any part of a filter group.
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSDoc for FilterGroupRenderProps says it provides the "full state needed to rebuild any part of a filter group", but the props omit several inputs that affect the default rendering/behavior (e.g., initialNumOptions, sliderStep / facetSliderSteps, and isHiddenFilterOptionFn). Either include those in FilterGroupRenderProps (so overrides can faithfully reproduce default behavior) or soften the wording to avoid overstating what’s provided.

Suggested change
* Provides the full state needed to rebuild any part of a filter group.
* Provides facet data and interaction handlers commonly needed to customize a filter group.

Copilot uses AI. Check for mistakes.
const componentOverrides = componentOverridesProp ?? context?.componentOverrides?.filterGroup;
const [isCollapsed, setIsCollapsed] = useState(false);

const toggleIsCollapsed = () => setIsCollapsed(!isCollapsed);
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toggleIsCollapsed uses setIsCollapsed(!isCollapsed), which can apply a stale value under React’s concurrent rendering / batched updates. Use the functional updater form (setIsCollapsed(prev => !prev)) to guarantee correct toggling.

Suggested change
const toggleIsCollapsed = () => setIsCollapsed(!isCollapsed);
const toggleIsCollapsed = () => setIsCollapsed(prev => !prev);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@esezen esezen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

Comment thread src/types.ts Outdated
initialBrowseResponse?: GetBrowseResultsResponse;
staticRequestConfigs?: Partial<RequestConfigs>;
useShopifyDefaults?: boolean;
componentOverrides?: Partial<PlpComponentOverrides>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Partial here? Also can we please document this in the stories for props

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove, probably all keys there will be not required anyway

Comment thread package.json
constructor-claude-bedrock[bot]

This comment was marked as outdated.

@esezen esezen requested a review from a team as a code owner April 9, 2026 17:54
Copy link
Copy Markdown

@constructor-claude-bedrock constructor-claude-bedrock Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This PR adds a well-structured componentOverrides system to FilterGroup, allowing consumers to replace any sub-component slot (root, header, optionsList, rangeSlider) with custom render functions or static nodes, backed by comprehensive tests and Storybook stories.

Inline comments: 7 discussions added

Overall Assessment: ⚠️ Needs Work

Comment thread package.json
Comment thread src/types.ts
Comment thread src/components/Filters/FilterGroup.tsx
Comment thread src/components/Filters/FilterGroup.tsx
Comment thread spec/components/Filters/FilterGroup.test.jsx
Comment thread src/stories/components/Filters/Filters.stories.tsx
Comment thread src/stories/components/Filters/Filters.stories.tsx
@esezen esezen merged commit 7d1aa91 into main Apr 9, 2026
12 checks passed
@esezen esezen deleted the cdx-418-plp-ui-feature-add-componentoverrides-to-filtergroup branch April 9, 2026 18:23
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