fix(ui): safari doesn't have find on iterators

This commit is contained in:
psychedelicious
2024-10-11 21:26:40 +10:00
committed by Mary Hipp Rogers
parent 1bb49b698f
commit e38f5b1576

View File

@@ -29,11 +29,10 @@ const onClose = () => {
$imageContextMenuState.setKey('isOpen', false);
};
const elToImageMap = new Map<HTMLDivElement, ImageDTO>();
const getImageDTOFromMap = (target: Node) => {
const parent = elToImageMap.keys().find((el) => el.contains(target));
return parent ? elToImageMap.get(parent) : undefined;
const getImageDTOFromMap = (target: Node): ImageDTO | undefined => {
const entry = Array.from(elToImageMap.entries()).find((entry) => entry[0].contains(target));
return entry?.[1];
};
export const useImageContextMenu = (imageDTO: ImageDTO | undefined, targetRef: RefObject<HTMLDivElement>) => {
useEffect(() => {
if (!targetRef.current || !imageDTO) {