Skip to content

Conversation

tenphi
Copy link
Member

@tenphi tenphi commented Jul 30, 2025

No description provided.

Copy link

changeset-bot bot commented Jul 30, 2025

🦋 Changeset detected

Latest commit: fd6cd1e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cube-dev/ui-kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jul 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cube-ui-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2025 2:28pm
cube-ui-kit-cursor ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2025 2:28pm

Copy link
Contributor

github-actions bot commented Jul 30, 2025

📦 NPM canary release

Deployed canary version 0.0.0-canary-220b76c.

Copy link
Contributor

github-actions bot commented Jul 30, 2025

🧪 Storybook is successfully deployed!

Copy link
Contributor

github-actions bot commented Jul 30, 2025

🏋️ Size limit report

Name Size Passed?
All 274.14 KB (+0.16% 🔺) Yes 🎉
Tree shaking (just a Button) 22.31 KB (-0.01% 🔽👏) Yes 🎉
Tree shaking (just an Icon) 11.41 KB (0% 🟰) Yes 🎉

Click here if you want to find out what is changed in this build

Copilot

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@tenphi tenphi requested a review from Copilot July 30, 2025 13:51
Copy link
Contributor

@Copilot 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 enhances the FilterPicker component to provide full support for the items prop, enabling data-driven rendering without requiring children elements. This addresses limitations where the FilterPicker had incomplete support for items-based configuration.

  • Added ItemWithKey interface to properly type items with keys, IDs, and children
  • Implemented comprehensive label extraction and sorting logic for items-based data
  • Enhanced type safety by replacing any types with proper type annotations

Reviewed Changes

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

Show a summary per file
File Description
FilterPicker.tsx Core implementation adding items prop support with sorting, label extraction, and type safety improvements
FilterPicker.stories.tsx Updated stories to demonstrate items prop usage and fixed test data setup
FilterListBox.stories.tsx Minor test data adjustment for consistency
Button.tsx Simplified icon rendering logic
.changeset/metal-pumpkins-appear.md Added changeset for the patch release


/** Ref to access internal ListBox state (from FilterListBox) */
listStateRef?: MutableRefObject<any | null>;
listStateRef?: MutableRefObject<unknown>;
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

The type change from any | null to unknown is too restrictive for a ref that should hold state objects. Consider using MutableRefObject<ListState<T> | null> or a more specific state type instead of unknown.

Suggested change
listStateRef?: MutableRefObject<unknown>;
listStateRef?: MutableRefObject<ListState<T> | null>;

Copilot uses AI. Check for mistakes.

id?: string | number;
textValue?: string;
children?: ItemWithKey[];
[key: string]: unknown;
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

[nitpick] The index signature [key: string]: unknown may be too permissive and could mask type errors. Consider making it optional with [key: string]?: unknown or being more specific about the expected additional properties.

Suggested change
[key: string]: unknown;
[key: string]?: unknown;

Copilot uses AI. Check for mistakes.

Comment on lines +587 to +595
const cloneWithNormalizedKey = (item: ReactElement) =>
cloneElement(item, {
key: normalizeKeyValue(item.key),
key: item.key ? normalizeKeyValue(item.key) : undefined,
});

const selected: ReactNode[] = [];
const unselected: ReactNode[] = [];

childrenArray.forEach((child: any) => {
childrenArray.forEach((child: ReactNode) => {
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

Setting key to undefined in cloneElement may cause React warnings or issues. React keys should be strings or numbers, not undefined. Consider using the original key or a fallback value.

Copilot uses AI. Check for mistakes.

const item = obj as ItemWithKey;
if (obj && Array.isArray(item.children)) {
// Section-like object – keep order, but sort its children
const sortedChildren = sortArray(item.children);
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

The sortArray function is called recursively for nested children without checking if sorting is actually needed. Consider adding a check to avoid unnecessary sorting when no items are selected.

Suggested change
const sortedChildren = sortArray(item.children);
const sortedChildren =
selectedSet.size > 0 ? sortArray(item.children) : item.children;

Copilot uses AI. Check for mistakes.

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.

1 participant