Skip to content

feat: add hook to sorting selected options on open with enable flag#43

Open
pbuba wants to merge 3 commits into
mainfrom
fix-bublikov-task-2
Open

feat: add hook to sorting selected options on open with enable flag#43
pbuba wants to merge 3 commits into
mainfrom
fix-bublikov-task-2

Conversation

@pbuba

@pbuba pbuba commented Apr 30, 2025

Copy link
Copy Markdown
  • add hook to sorting selected options on open
  • add sorting hook for multi-select component
  • add enable flag

@vercel

vercel Bot commented Apr 30, 2025

Copy link
Copy Markdown

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

Name Status Preview Comments Updated (UTC)
canary ❌ Failed (Inspect) May 2, 2025 7:39am

if (enable && isOpen) {
setSnapshotIds(new Set(selectedItems.map(item => item.id)))
}
}, [isOpen, enable])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We can avoid using useEffect here — especially since selectedItems might not be updated at the right time.
You already have the onOpenChange event on DropdownMenu.Root.

Comment thread packages/ui/src/hooks/use-sorted-options-on-open.tsx
searchValue={searchTag}
handleChangeSearchValue={setSearchTag}
error={errors.tags?.message?.toString()}
enableSortOnOpen

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actually, this should be the default behavior, so we can remove this prop and always apply sorting

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