Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fixed InlineBadgePopoverMenu

Steven Tey72dca0df04c1
diff --git a/apps/web/ui/partners/rewards/inline-badge-popover.tsx b/apps/web/ui/partners/rewards/inline-badge-popover.tsx
index fac6c486a3..9ea3350cb6 100644
--- a/apps/web/ui/partners/rewards/inline-badge-popover.tsx
+++ b/apps/web/ui/partners/rewards/inline-badge-popover.tsx
@@ -97,17 +97,13 @@ export function InlineBadgePopoverMenu<T extends any>({
}) {
const isMultiSelect = Array.isArray(selectedValue);
- const { isOpen, setIsOpen } = useContext(InlineBadgePopoverContext);
-
const scrollRef = useRef<HTMLDivElement>(null);
const { scrollProgress, updateScrollProgress } = useScrollProgress(scrollRef);
const [sortedItems, setSortedItems] = useState<MenuItem<T>[]>(items);
- // Sort items so that the selected values are always at the top, but only when the popover is closed
+ // Sort items so that the selected values are always at the top
useEffect(() => {
- if (isOpen) return;
-
setSortedItems(
items.sort((a, b) => {
const aSelected = isMultiSelect
@@ -120,11 +116,11 @@ export function InlineBadgePopoverMenu<T extends any>({
// First sort by whether the items are selected
if (aSelected !== bSelected) return aSelected ? -1 : 1;
- // Then sort alphabetically
- return a.text.localeCompare(b.text);
+ // Then sort as per the original order of the items
+ return items.indexOf(a) - items.indexOf(b);
}),
);
- }, [isOpen, items, isMultiSelect, selectedValue]);
+ }, [items, isMultiSelect, selectedValue]);
return (
<Command loop className="focus:outline-none">
@@ -151,7 +147,6 @@ export function InlineBadgePopoverMenu<T extends any>({
onSelect={() => {
itemOnSelect?.();
onSelect?.(value);
- !isMultiSelect && setIsOpen(false);
}}
className="flex cursor-pointer items-center justify-between rounded-md px-1.5 py-1 transition-colors duration-150 data-[selected=true]:bg-neutral-100"
>