chore(collections/calendar): experiment with avoiding floating buttons

This commit is contained in:
Elian Doran
2025-09-06 13:09:24 +03:00
parent e8024ce341
commit 6c4ac347db
2 changed files with 21 additions and 2 deletions

View File

@@ -642,3 +642,21 @@ export function useResizeObserver(ref: RefObject<HTMLElement>, callback: () => v
return () => observer.disconnect();
}, [ callback, ref ]);
}
export function useFloatingButtonsWidth() {
const [ width, setWidth ] = useState(0);
const parentComponent = useContext(ParentComponent);
const containerRef = useRef<HTMLElement>(null);
useEffect(() => {
const containerEl = parentComponent?.$widget
.closest(".note-split")
.find(".floating-buttons-children")[0];
containerRef.current = (containerEl as HTMLElement | undefined) ?? null;
});
useResizeObserver(containerRef, () => {
console.log("Got width ", containerRef.current?.getBoundingClientRect().width);
setWidth(containerRef.current?.getBoundingClientRect().width ?? 0);
});
return width;
}