import React, { type ReactNode } from "react"; import clsx from "clsx"; import * as Popover from "@radix-ui/react-popover"; import { useDevice } from "./App"; import { Island } from "./Island"; import { isInteractive } from "../utils"; interface PropertiesPopoverProps { className?: string; container: HTMLDivElement | null; children: ReactNode; style?: object; onClose: () => void; onKeyDown?: React.KeyboardEventHandler; onPointerLeave?: React.PointerEventHandler; onFocusOutside?: Popover.DismissableLayerProps["onFocusOutside"]; onPointerDownOutside?: Popover.DismissableLayerProps["onPointerDownOutside"]; } export const PropertiesPopover = React.forwardRef< HTMLDivElement, PropertiesPopoverProps >( ( { className, container, children, style, onClose, onKeyDown, onFocusOutside, onPointerLeave, onPointerDownOutside, }, ref, ) => { const device = useDevice(); return ( { e.stopPropagation(); // prevents focusing the trigger e.preventDefault(); // return focus to excalidraw container unless // user focuses an interactive element, such as a button, or // enters the text editor by clicking on canvas with the text tool if (container && !isInteractive(document.activeElement)) { container.focus(); } onClose(); }} > {children} ); }, );