@brightlocal/ui-components 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/combobox.js CHANGED
@@ -6,9 +6,9 @@ import { defaultFilter as P } from "cmdk";
6
6
  import { cn as y } from "@brightlocal/ui-components/lib/utils";
7
7
  import { Popover as G, PopoverContent as U, PopoverTrigger as _ } from "@brightlocal/ui-components/popover";
8
8
  import { Command as $, CommandEmpty as q, CommandGroup as z, CommandInput as D, CommandItem as H, CommandList as V, CommandSeparator as B } from "@brightlocal/ui-components/command";
9
- const T = t.createContext(null);
9
+ const F = t.createContext(null);
10
10
  function I() {
11
- const e = t.useContext(T);
11
+ const e = t.useContext(F);
12
12
  if (!e)
13
13
  throw new Error("Combobox components must be used within a <Combobox>");
14
14
  return e;
@@ -18,14 +18,14 @@ function ue({
18
18
  onValueChange: o,
19
19
  open: n,
20
20
  onOpenChange: r,
21
- shouldFilter: i = !0,
22
- disabled: d = !1,
23
- itemToStringValue: u,
24
- children: b
21
+ shouldFilter: d = !0,
22
+ disabled: u = !1,
23
+ itemToStringValue: c,
24
+ children: m
25
25
  }) {
26
- const [h, v] = t.useState(""), [f, w] = t.useState(!1), [C, s] = t.useState(
26
+ const [h, v] = t.useState(""), [f, w] = t.useState(!1), [C, i] = t.useState(
27
27
  () => /* @__PURE__ */ new Map()
28
- ), p = e !== void 0, x = n !== void 0, c = p ? e : h, m = x ? n : f, g = t.useCallback(
28
+ ), p = e !== void 0, x = n !== void 0, s = p ? e : h, b = x ? n : f, g = t.useCallback(
29
29
  (l) => {
30
30
  x || w(l), r?.(l);
31
31
  },
@@ -36,36 +36,36 @@ function ue({
36
36
  },
37
37
  [p, o]
38
38
  ), N = t.useCallback((l, L) => {
39
- s((S) => {
39
+ i((S) => {
40
40
  if (S.get(l) === L) return S;
41
- const F = new Map(S);
42
- return F.set(l, L), F;
41
+ const T = new Map(S);
42
+ return T.set(l, L), T;
43
43
  });
44
44
  }, []), R = t.useMemo(
45
45
  () => ({
46
- open: m,
46
+ open: b,
47
47
  setOpen: g,
48
- value: c,
48
+ value: s,
49
49
  onValueChange: k,
50
- shouldFilter: i,
51
- disabled: d,
50
+ shouldFilter: d,
51
+ disabled: u,
52
52
  itemLabels: C,
53
53
  registerItem: N,
54
- itemToStringValue: u
54
+ itemToStringValue: c
55
55
  }),
56
56
  [
57
- m,
57
+ b,
58
58
  g,
59
- c,
59
+ s,
60
60
  k,
61
- i,
62
61
  d,
62
+ u,
63
63
  C,
64
64
  N,
65
- u
65
+ c
66
66
  ]
67
67
  );
68
- return /* @__PURE__ */ a(T.Provider, { value: R, children: /* @__PURE__ */ a(G, { open: m, onOpenChange: g, children: b }) });
68
+ return /* @__PURE__ */ a(F.Provider, { value: R, children: /* @__PURE__ */ a(G, { open: b, onOpenChange: g, children: m }) });
69
69
  }
70
70
  const J = O(
71
71
  [
@@ -109,12 +109,12 @@ const J = O(
109
109
  variant: o,
110
110
  dataHook: n,
111
111
  error: r,
112
- trackingEl: i,
113
- trackingLabel: d,
114
- children: u,
115
- ...b
112
+ trackingEl: d,
113
+ trackingLabel: u,
114
+ children: c,
115
+ ...m
116
116
  }, h) => {
117
- const { open: v, disabled: f, value: w } = I(), C = t.useId(), s = !w, p = r || b["aria-invalid"] === !0 || b["aria-invalid"] === "true";
117
+ const { open: v, disabled: f, value: w } = I(), C = t.useId(), i = !w, p = r || m["aria-invalid"] === !0 || m["aria-invalid"] === "true";
118
118
  return /* @__PURE__ */ a(_, { asChild: !0, children: /* @__PURE__ */ E(
119
119
  "button",
120
120
  {
@@ -129,17 +129,17 @@ const J = O(
129
129
  e
130
130
  ),
131
131
  "data-hook": n,
132
- "data-placeholder": s,
132
+ "data-placeholder": i,
133
133
  "data-slot": "combobox-trigger",
134
134
  "data-state": v ? "open" : "closed",
135
- "data-tracking-el": i || "combobox-trigger",
136
- "data-tracking-label": d,
137
- disabled: f || b.disabled,
135
+ "data-tracking-el": d || "combobox-trigger",
136
+ "data-tracking-label": u,
137
+ disabled: f || m.disabled,
138
138
  role: "combobox",
139
139
  type: "button",
140
- ...b,
140
+ ...m,
141
141
  children: [
142
- u,
142
+ c,
143
143
  /* @__PURE__ */ a(
144
144
  j,
145
145
  {
@@ -154,7 +154,7 @@ const J = O(
154
154
  );
155
155
  K.displayName = "ComboboxTrigger";
156
156
  function ce({ placeholder: e, className: o }) {
157
- const { value: n, itemLabels: r } = I(), i = n ? r.get(n) || n : e;
157
+ const { value: n, itemLabels: r } = I(), d = n ? r.get(n) || n : e;
158
158
  return /* @__PURE__ */ a(
159
159
  "span",
160
160
  {
@@ -163,7 +163,7 @@ function ce({ placeholder: e, className: o }) {
163
163
  o
164
164
  ),
165
165
  "data-slot": "combobox-value",
166
- children: i
166
+ children: d
167
167
  }
168
168
  );
169
169
  }
@@ -172,40 +172,44 @@ function le({
172
172
  className: o,
173
173
  children: n,
174
174
  align: r = "start",
175
- side: i = "bottom",
176
- sideOffset: d,
177
- avoidCollisions: u,
178
- hideList: b = !1
175
+ side: d = "bottom",
176
+ sideOffset: u,
177
+ avoidCollisions: c,
178
+ hideList: m = !1
179
179
  }) {
180
180
  const { open: h, shouldFilter: v, itemToStringValue: f } = I(), [w, C] = t.useState(
181
181
  null
182
- ), s = t.useRef(null), p = t.useCallback((c) => {
183
- if (s.current?.(), s.current = null, !c) return;
184
- let m = !1;
182
+ ), i = t.useRef(null), p = t.useCallback((s) => {
183
+ if (i.current?.(), i.current = null, !s) return;
184
+ let b = !1;
185
185
  const g = (l) => {
186
- m || (l === "top" || l === "bottom") && (m = !0, k.disconnect(), C(l));
186
+ b || (l === "top" || l === "bottom") && (b = !0, k.disconnect(), C(l));
187
187
  }, k = new MutationObserver(() => {
188
- g(c.getAttribute("data-side"));
188
+ g(s.getAttribute("data-side"));
189
189
  });
190
- k.observe(c, {
190
+ k.observe(s, {
191
191
  attributes: !0,
192
192
  attributeFilter: ["data-side"]
193
193
  });
194
194
  let N = 0, R = 0;
195
195
  N = requestAnimationFrame(() => {
196
196
  R = requestAnimationFrame(() => {
197
- g(c.getAttribute("data-side"));
197
+ g(s.getAttribute("data-side"));
198
198
  });
199
- }), s.current = () => {
200
- m = !0, k.disconnect(), cancelAnimationFrame(N), cancelAnimationFrame(R);
199
+ }), i.current = () => {
200
+ b = !0, k.disconnect(), cancelAnimationFrame(N), cancelAnimationFrame(R);
201
201
  };
202
202
  }, []);
203
203
  t.useEffect(() => {
204
- h || (s.current?.(), s.current = null, C(null));
204
+ if (!h) {
205
+ i.current?.(), i.current = null;
206
+ const s = setTimeout(() => C(null), 150);
207
+ return () => clearTimeout(s);
208
+ }
205
209
  }, [h]);
206
210
  const x = t.useMemo(() => {
207
211
  if (f)
208
- return (c, m, g) => P(f(c), m, g);
212
+ return (s, b, g) => P(f(s), b, g);
209
213
  }, [f]);
210
214
  return /* @__PURE__ */ a(
211
215
  U,
@@ -213,17 +217,17 @@ function le({
213
217
  ref: p,
214
218
  align: r,
215
219
  "aria-label": "Options",
216
- avoidCollisions: u,
220
+ avoidCollisions: c,
217
221
  className: y("w-[var(--radix-popover-trigger-width)] p-0", o),
218
222
  "data-slot": "combobox-popover",
219
- side: w ?? i,
220
- sideOffset: d,
223
+ side: w ?? d,
224
+ sideOffset: u,
221
225
  children: /* @__PURE__ */ a(
222
226
  $,
223
227
  {
224
228
  className: y(
225
229
  "border-0 shadow-none",
226
- b && "[&_[data-slot='command-input-wrapper']]:border-b-0"
230
+ m && "[&_[data-slot='command-input-wrapper']]:border-b-0"
227
231
  ),
228
232
  "data-slot": "combobox-command",
229
233
  dataHook: e || "combobox-command",
@@ -249,9 +253,9 @@ function Z(e, o, n) {
249
253
  const r = new RegExp(
250
254
  `(${o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
251
255
  "gi"
252
- ), i = e.split(r);
253
- return /* @__PURE__ */ a("span", { children: i.map(
254
- (d, u) => u % 2 === 1 ? /* @__PURE__ */ a("span", { className: n, children: d }, u) : /* @__PURE__ */ a(t.Fragment, { children: d }, u)
256
+ ), d = e.split(r);
257
+ return /* @__PURE__ */ a("span", { children: d.map(
258
+ (u, c) => c % 2 === 1 ? /* @__PURE__ */ a("span", { className: n, children: u }, c) : /* @__PURE__ */ a(t.Fragment, { children: u }, c)
255
259
  ) });
256
260
  }
257
261
  const ee = t.forwardRef(
@@ -260,35 +264,35 @@ const ee = t.forwardRef(
260
264
  label: o,
261
265
  dataHook: n,
262
266
  children: r,
263
- className: i,
264
- highlight: d,
265
- highlightClassName: u,
266
- keywords: b,
267
+ className: d,
268
+ highlight: u,
269
+ highlightClassName: c,
270
+ keywords: m,
267
271
  ...h
268
272
  }, v) => {
269
- const { value: f, onValueChange: w, setOpen: C, registerItem: s } = I(), p = f === e, x = t.useMemo(() => o || (typeof r == "string" ? r : typeof r == "number" ? String(r) : e), [o, r, e]), c = t.useRef(s);
273
+ const { value: f, onValueChange: w, setOpen: C, registerItem: i } = I(), p = f === e, x = t.useMemo(() => o || (typeof r == "string" ? r : typeof r == "number" ? String(r) : e), [o, r, e]), s = t.useRef(i);
270
274
  t.useEffect(() => {
271
- c.current = s;
272
- }, [s]), t.useEffect(() => {
273
- c.current(e, x);
275
+ s.current = i;
276
+ }, [i]), t.useEffect(() => {
277
+ s.current(e, x);
274
278
  }, [e, x]);
275
- const m = () => {
279
+ const b = () => {
276
280
  w(e === f ? "" : e), C(!1);
277
- }, g = () => d && typeof r == "string" ? Z(
281
+ }, g = () => u && typeof r == "string" ? Z(
278
282
  r,
279
- d,
280
- u || "text-sm leading-normal font-semibold"
283
+ u,
284
+ c || "text-sm leading-normal font-semibold"
281
285
  ) : r;
282
286
  return /* @__PURE__ */ E(
283
287
  H,
284
288
  {
285
289
  ref: v,
286
- className: y("justify-between", i),
290
+ className: y("justify-between", d),
287
291
  "data-slot": "combobox-item",
288
292
  dataHook: n,
289
- keywords: b ? [x, ...b] : [x],
293
+ keywords: m ? [x, ...m] : [x],
290
294
  value: e,
291
- onSelect: m,
295
+ onSelect: b,
292
296
  ...h,
293
297
  children: [
294
298
  g(),
@@ -307,7 +311,7 @@ const ee = t.forwardRef(
307
311
  ee.displayName = "ComboboxItem";
308
312
  const oe = t.forwardRef((e, o) => /* @__PURE__ */ a(B, { ref: o, "data-slot": "combobox-separator", ...e }));
309
313
  oe.displayName = "ComboboxSeparator";
310
- function be({ className: e, children: o }) {
314
+ function me({ className: e, children: o }) {
311
315
  return /* @__PURE__ */ a(
312
316
  "div",
313
317
  {
@@ -340,7 +344,7 @@ export {
340
344
  Q as ComboboxInput,
341
345
  ee as ComboboxItem,
342
346
  W as ComboboxList,
343
- be as ComboboxLoading,
347
+ me as ComboboxLoading,
344
348
  oe as ComboboxSeparator,
345
349
  K as ComboboxTrigger,
346
350
  ce as ComboboxValue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightlocal/ui-components",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "BrightLocal Design System UI Components",
5
5
  "type": "module",
6
6
  "private": false,
@@ -105,8 +105,8 @@
105
105
  "vite-bundle-visualizer": "^1.2.1",
106
106
  "vite-plugin-dts": "^4.5.4",
107
107
  "vite-plugin-lib-inject-css": "^2.2.2",
108
- "@workspace/eslint-config": "0.0.0",
109
- "@workspace/typescript-config": "0.0.0"
108
+ "@workspace/typescript-config": "0.0.0",
109
+ "@workspace/eslint-config": "0.0.0"
110
110
  },
111
111
  "publishConfig": {
112
112
  "access": "public",
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import * as React from "react";
4
+ import { motion, AnimatePresence } from "framer-motion";
4
5
  import { X } from "@brightlocal/icons";
5
6
 
6
7
  import { cn } from "@brightlocal/ui-components/lib/utils";
@@ -119,45 +120,31 @@ function InputList({
119
120
  className,
120
121
  }: InputListProps) {
121
122
  const [inputValue, setInputValue] = React.useState("");
122
- const [removingIndices, setRemovingIndices] = React.useState<Set<number>>(
123
- () => new Set()
124
- );
125
- const [addingIndices, setAddingIndices] = React.useState<Set<number>>(
126
- () => new Set()
127
- );
128
123
 
129
- // Expand newly added items after initial collapsed paint (triggers CSS transition)
130
- React.useEffect(() => {
131
- if (addingIndices.size === 0) return;
132
- const frame = requestAnimationFrame(() => {
133
- setAddingIndices(new Set());
134
- });
135
- return () => cancelAnimationFrame(frame);
136
- }, [addingIndices]);
137
- const valueRef = React.useRef(value);
138
- React.useEffect(() => {
139
- valueRef.current = value;
140
- }, [value]);
141
- const timersRef = React.useRef(new Set<ReturnType<typeof setTimeout>>());
142
- React.useEffect(() => {
143
- const timers = timersRef.current;
144
- return () => {
145
- timers.forEach(clearTimeout);
146
- timers.clear();
147
- };
148
- }, []);
149
-
150
- // Stable keys so remaining items don't remount (and re-animate) on removal
124
+ // Stable keys so AnimatePresence can track items across additions/removals
151
125
  const nextIdRef = React.useRef(value.length);
152
126
  const [stableKeys, setStableKeys] = React.useState<number[]>(() =>
153
127
  value.map((_, i) => i)
154
128
  );
129
+
130
+ // Sync keys when value changes externally (not via addItems/removeItem).
131
+ // Simple appends preserve existing keys; other changes (removal, reorder)
132
+ // regenerate all keys to avoid incorrect exit animations.
155
133
  React.useEffect(() => {
156
134
  setStableKeys((prev) => {
157
- if (prev.length !== value.length) {
158
- return value.map(() => nextIdRef.current++);
135
+ if (prev.length === value.length) return prev;
136
+ if (value.length > prev.length) {
137
+ // Append: preserve existing keys, generate new ones
138
+ return [
139
+ ...prev,
140
+ ...Array.from(
141
+ { length: value.length - prev.length },
142
+ () => nextIdRef.current++
143
+ ),
144
+ ];
159
145
  }
160
- return prev;
146
+ // Removal or reorder: regenerate all keys
147
+ return value.map(() => nextIdRef.current++);
161
148
  });
162
149
  }, [value]);
163
150
 
@@ -173,13 +160,6 @@ function InputList({
173
160
  maxItems !== undefined ? maxItems - value.length : Infinity;
174
161
  const toAdd = trimmed.slice(0, available);
175
162
  if (toAdd.length) {
176
- const prefersReducedMotion = window.matchMedia(
177
- "(prefers-reduced-motion: reduce)"
178
- ).matches;
179
- if (!prefersReducedMotion) {
180
- const startIndex = value.length;
181
- setAddingIndices(new Set(toAdd.map((_, i) => startIndex + i)));
182
- }
183
163
  setStableKeys((prev) => [
184
164
  ...prev,
185
165
  ...toAdd.map(() => nextIdRef.current++),
@@ -193,30 +173,10 @@ function InputList({
193
173
 
194
174
  const removeItem = React.useCallback(
195
175
  (index: number) => {
196
- const prefersReducedMotion = window.matchMedia(
197
- "(prefers-reduced-motion: reduce)"
198
- ).matches;
199
-
200
- if (prefersReducedMotion) {
201
- setStableKeys((prev) => prev.filter((_, i) => i !== index));
202
- onValueChange(valueRef.current.filter((_, i) => i !== index));
203
- return;
204
- }
205
-
206
- setRemovingIndices((prev) => new Set(prev).add(index));
207
- const timer = setTimeout(() => {
208
- timersRef.current.delete(timer);
209
- setRemovingIndices((prev) => {
210
- const next = new Set(prev);
211
- next.delete(index);
212
- return next;
213
- });
214
- setStableKeys((prev) => prev.filter((_, i) => i !== index));
215
- onValueChange(valueRef.current.filter((_, i) => i !== index));
216
- }, 200);
217
- timersRef.current.add(timer);
176
+ setStableKeys((prev) => prev.filter((_, i) => i !== index));
177
+ onValueChange(value.filter((_, i) => i !== index));
218
178
  },
219
- [onValueChange]
179
+ [value, onValueChange]
220
180
  );
221
181
 
222
182
  const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
@@ -252,55 +212,63 @@ function InputList({
252
212
  </ul>
253
213
  ) : value.length > 0 ? (
254
214
  <ul
255
- className="flex flex-col"
215
+ className="flex flex-col gap-2"
256
216
  data-hook={`${dataHook}-list`}
257
217
  data-slot="list"
258
218
  >
259
- {value.map((item, index) => {
260
- const isRemoving = removingIndices.has(index);
261
- const isAdding = addingIndices.has(index);
262
- const isCollapsed = isAdding || isRemoving;
263
- return (
264
- <li
219
+ <AnimatePresence initial={false}>
220
+ {value.map((item, index) => (
221
+ <motion.li
265
222
  key={stableKeys[index]}
266
- className={cn(
267
- "grid transition-[grid-template-rows,opacity,margin-bottom] ease-out",
268
- isCollapsed
269
- ? "mb-0 grid-rows-[0fr] opacity-0"
270
- : "mb-2 grid-rows-[1fr] opacity-100 last:mb-0",
271
- isRemoving ? "duration-200" : "duration-300"
272
- )}
223
+ layout
224
+ animate={{ opacity: 1, scale: 1 }}
273
225
  data-hook={`${dataHook}-item-${index}`}
274
226
  data-slot="item"
227
+ exit={{
228
+ opacity: 0,
229
+ scale: 0.8,
230
+ transition: {
231
+ opacity: { duration: 0.15 },
232
+ scale: { duration: 0.12 },
233
+ },
234
+ }}
235
+ initial={{ opacity: 0, scale: 0.8 }}
236
+ transition={{
237
+ opacity: { duration: 0.15 },
238
+ scale: { duration: 0.15 },
239
+ layout: {
240
+ type: "spring",
241
+ stiffness: 500,
242
+ damping: 35,
243
+ },
244
+ }}
275
245
  >
276
- <div className="overflow-hidden">
277
- <div className="bg-card flex items-center gap-4 rounded-lg py-2 pr-2 pl-4">
278
- <ItemContent>
279
- <ItemTitle>{item}</ItemTitle>
280
- </ItemContent>
281
- <ItemActions>
282
- <button
283
- aria-label={`Remove ${item}`}
284
- className={cn(
285
- "inline-flex size-9 cursor-pointer items-center justify-center rounded-full",
286
- "text-muted-foreground",
287
- "focus-visible:shadow-default outline-none",
288
- "transition-colors duration-150 ease-in-out",
289
- "disabled:pointer-events-none disabled:opacity-50"
290
- )}
291
- data-hook={`${dataHook}-remove-${index}`}
292
- disabled={disabled || isRemoving}
293
- type="button"
294
- onClick={() => removeItem(index)}
295
- >
296
- <X />
297
- </button>
298
- </ItemActions>
299
- </div>
246
+ <div className="bg-card flex items-center gap-4 rounded-lg py-2 pr-2 pl-4">
247
+ <ItemContent>
248
+ <ItemTitle>{item}</ItemTitle>
249
+ </ItemContent>
250
+ <ItemActions>
251
+ <button
252
+ aria-label={`Remove ${item}`}
253
+ className={cn(
254
+ "inline-flex size-9 cursor-pointer items-center justify-center rounded-full",
255
+ "text-muted-foreground",
256
+ "focus-visible:shadow-default outline-none",
257
+ "transition-colors duration-150 ease-in-out",
258
+ "disabled:pointer-events-none disabled:opacity-50"
259
+ )}
260
+ data-hook={`${dataHook}-remove-${index}`}
261
+ disabled={disabled}
262
+ type="button"
263
+ onClick={() => removeItem(index)}
264
+ >
265
+ <X />
266
+ </button>
267
+ </ItemActions>
300
268
  </div>
301
- </li>
302
- );
303
- })}
269
+ </motion.li>
270
+ ))}
271
+ </AnimatePresence>
304
272
  </ul>
305
273
  ) : null}
306
274
 
@@ -327,34 +295,36 @@ function InputList({
327
295
  </Button>
328
296
  </div>
329
297
 
330
- {/* Description */}
331
- {description && (
332
- <FieldDescription
333
- data-slot="input-list-description"
334
- dataHook={`${dataHook}-description`}
335
- >
336
- {description}
337
- </FieldDescription>
338
- )}
339
-
340
- {/* Count indicator — always shown when maxItems is set */}
341
- {maxItems !== undefined && (
342
- <FieldDescription
343
- data-slot="input-list-count"
344
- dataHook={`${dataHook}-count`}
345
- >
346
- {value.length}/{maxItems}
347
- </FieldDescription>
348
- )}
349
-
350
- {/* Error message */}
351
- {error && errorMessage && (
298
+ {/* Error message replaces description and counter */}
299
+ {error && errorMessage ? (
352
300
  <FieldError
353
301
  data-slot="input-list-error"
354
302
  dataHook={`${dataHook}-error`}
355
303
  >
356
304
  {errorMessage}
357
305
  </FieldError>
306
+ ) : (
307
+ <>
308
+ {/* Description */}
309
+ {description && (
310
+ <FieldDescription
311
+ data-slot="input-list-description"
312
+ dataHook={`${dataHook}-description`}
313
+ >
314
+ {description}
315
+ </FieldDescription>
316
+ )}
317
+
318
+ {/* Count indicator — always shown when maxItems is set */}
319
+ {maxItems !== undefined && (
320
+ <FieldDescription
321
+ data-slot="input-list-count"
322
+ dataHook={`${dataHook}-count`}
323
+ >
324
+ {value.length}/{maxItems}
325
+ </FieldDescription>
326
+ )}
327
+ </>
358
328
  )}
359
329
  </div>
360
330
  </div>
@@ -443,13 +443,17 @@ function ComboboxContent({
443
443
  };
444
444
  }, []);
445
445
 
446
- // Reset locked side when popover closes
446
+ // Cleanup observers on close, but delay the lockedSide reset until
447
+ // the exit animation finishes (150ms) so the side prop stays locked
448
+ // and the dropdown doesn't visibly flip during the fade-out/zoom-out.
447
449
  React.useEffect(() => {
448
450
  if (!open) {
449
451
  cleanupRef.current?.();
450
452
  cleanupRef.current = null;
451
- setLockedSide(null);
453
+ const timer = setTimeout(() => setLockedSide(null), 150);
454
+ return () => clearTimeout(timer);
452
455
  }
456
+ return undefined;
453
457
  }, [open]);
454
458
 
455
459
  const filter = React.useMemo(() => {