fix(map): stabilize layers menu and offline cache UX

This commit is contained in:
Codex
2026-08-09 20:27:06 +03:00
parent b70e165910
commit f645725e8c
8 changed files with 72 additions and 10 deletions
+26 -1
View File
@@ -107,7 +107,32 @@ export function Dropdown({
useLayoutEffect(() => {
if (!isOpen) return;
updatePosition();
}, [isOpen, updatePosition]);
const surface = surfaceRef.current;
const anchor = anchorElement ?? triggerElement;
if (!surface || typeof ResizeObserver === "undefined") {
const frame = window.requestAnimationFrame(updatePosition);
return () => window.cancelAnimationFrame(frame);
}
let frame: number | null = null;
const schedulePositionUpdate = () => {
if (frame !== null) return;
frame = window.requestAnimationFrame(() => {
frame = null;
updatePosition();
});
};
const resizeObserver = new ResizeObserver(schedulePositionUpdate);
resizeObserver.observe(surface);
if (anchor) resizeObserver.observe(anchor);
schedulePositionUpdate();
return () => {
resizeObserver.disconnect();
if (frame !== null) window.cancelAnimationFrame(frame);
};
}, [anchorElement, isOpen, triggerElement, updatePosition]);
useEffect(() => {
if (!isOpen) return;