@diwauhris/ui 1.7.32 → 1.7.33
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/lib/index.cjs +6 -2
- package/lib/index.mjs +6 -2
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1246,15 +1246,19 @@ function Combobox({ value: controlledValue, defaultValue = "", onChange, options
|
|
|
1246
1246
|
overscrollBehavior: "contain"
|
|
1247
1247
|
});
|
|
1248
1248
|
};
|
|
1249
|
+
const closeOnScroll = (e) => {
|
|
1250
|
+
if (listRef.current && listRef.current.contains(e.target)) return;
|
|
1251
|
+
setIsOpen(false);
|
|
1252
|
+
};
|
|
1249
1253
|
const raf = requestAnimationFrame(updatePosition);
|
|
1250
|
-
window.addEventListener("scroll",
|
|
1254
|
+
window.addEventListener("scroll", closeOnScroll, {
|
|
1251
1255
|
capture: true,
|
|
1252
1256
|
passive: true
|
|
1253
1257
|
});
|
|
1254
1258
|
window.addEventListener("resize", updatePosition);
|
|
1255
1259
|
return () => {
|
|
1256
1260
|
cancelAnimationFrame(raf);
|
|
1257
|
-
window.removeEventListener("scroll",
|
|
1261
|
+
window.removeEventListener("scroll", closeOnScroll, { capture: true });
|
|
1258
1262
|
window.removeEventListener("resize", updatePosition);
|
|
1259
1263
|
};
|
|
1260
1264
|
}, [isOpen]);
|
package/lib/index.mjs
CHANGED
|
@@ -1222,15 +1222,19 @@ function Combobox({ value: controlledValue, defaultValue = "", onChange, options
|
|
|
1222
1222
|
overscrollBehavior: "contain"
|
|
1223
1223
|
});
|
|
1224
1224
|
};
|
|
1225
|
+
const closeOnScroll = (e) => {
|
|
1226
|
+
if (listRef.current && listRef.current.contains(e.target)) return;
|
|
1227
|
+
setIsOpen(false);
|
|
1228
|
+
};
|
|
1225
1229
|
const raf = requestAnimationFrame(updatePosition);
|
|
1226
|
-
window.addEventListener("scroll",
|
|
1230
|
+
window.addEventListener("scroll", closeOnScroll, {
|
|
1227
1231
|
capture: true,
|
|
1228
1232
|
passive: true
|
|
1229
1233
|
});
|
|
1230
1234
|
window.addEventListener("resize", updatePosition);
|
|
1231
1235
|
return () => {
|
|
1232
1236
|
cancelAnimationFrame(raf);
|
|
1233
|
-
window.removeEventListener("scroll",
|
|
1237
|
+
window.removeEventListener("scroll", closeOnScroll, { capture: true });
|
|
1234
1238
|
window.removeEventListener("resize", updatePosition);
|
|
1235
1239
|
};
|
|
1236
1240
|
}, [isOpen]);
|