Skip to content

Conversation

@tenphi
Copy link
Member

@tenphi tenphi commented Aug 6, 2025

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Aug 6, 2025

🦋 Changeset detected

Latest commit: 50133ed

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

@tenphi tenphi requested a review from Copilot August 6, 2025 08:23
@vercel
Copy link

vercel bot commented Aug 6, 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 Aug 6, 2025 8:23am
cube-ui-kit-cursor ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 8:23am

@cursor
Copy link

cursor bot commented Aug 6, 2025

🚨 Bugbot Trial Expired

Your team's Bugbot trial has expired. Please contact your team administrator to turn on the paid plan to continue using Bugbot.

A team admin can activate the plan in the Cursor dashboard.

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 fixes the FilterPicker sorting behavior in controlled mode by modifying how cached order is managed during popover state changes.

  • Updates caching logic to clear cached order when popover closes instead of checking popover state
  • Removes conditional logic that relied on isPopoverOpen state for cache reuse
  • Ensures sorted order is recomputed fresh for each popover opening session

Reviewed Changes

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

File Description
src/components/fields/FilterPicker/FilterPicker.tsx Modified cache management logic for children and items order, clearing cache on popover close
.changeset/gold-bats-live.md Added changeset entry documenting the fix

// Reuse the cached order if we have it. We only want to compute the sorted
// order once per pop-over opening session. The cache is cleared when the
// pop-over closes so the next opening can recompute.
if (cachedChildrenOrder.current) {
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

The simplified caching logic may cause issues in controlled mode. The original code checked !isPopoverOpen to avoid using stale cache when the popover is open. Without this check, the cache could be used even when the popover is open and selections have changed, potentially showing outdated sorting.

Suggested change
if (cachedChildrenOrder.current) {
// Only use the cache if the popover is closed to avoid stale sorting.
if (cachedChildrenOrder.current && !isPopoverOpen) {

Copilot uses AI. Check for mistakes.
if (!isPopoverOpen && cachedItemsOrder.current) {
// Reuse the cached order if we have it. We only compute the sorted array
// once when the pop-over is opened. Cache is cleared on close.
if (cachedItemsOrder.current) {
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

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

Similar to the children order issue, removing the !isPopoverOpen check may cause the cached items order to be used inappropriately when the popover is open and the sorting should be recomputed based on current selections.

Suggested change
if (cachedItemsOrder.current) {
if (cachedItemsOrder.current && !isPopoverOpen) {

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2025

📦 NPM canary release

Deployed canary version 0.0.0-canary-a3aca12.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2025

🏋️ Size limit report

Name Size Passed?
All 275.07 KB (+0.01% 🔺) Yes 🎉
Tree shaking (just a Button) 22.95 KB (0% 🟰) Yes 🎉
Tree shaking (just an Icon) 12.07 KB (0% 🟰) Yes 🎉

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

@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2025

🧪 Storybook is successfully deployed!

@tenphi tenphi merged commit c383d29 into main Aug 6, 2025
14 checks passed
@tenphi tenphi deleted the fix-filter-picker-controlled-mode branch August 6, 2025 09:04
@github-actions github-actions bot mentioned this pull request Aug 6, 2025
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.

2 participants