@sanity/ui 1.3.4 → 1.5.0

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/dist/index.d.ts CHANGED
@@ -1197,6 +1197,7 @@ export declare interface MenuButtonProps {
1197
1197
  id: string
1198
1198
  menu?: React.ReactElement
1199
1199
  onClose?: () => void
1200
+ onOpen?: () => void
1200
1201
  /**
1201
1202
  * @deprecated Use `popover={{placement: 'top'}}` instead.
1202
1203
  */
package/dist/index.esm.js CHANGED
@@ -7984,6 +7984,7 @@ const MenuButton = forwardRef(function MenuButton2(props, ref) {
7984
7984
  id,
7985
7985
  menu: menuProp,
7986
7986
  onClose,
7987
+ onOpen,
7987
7988
  placement: deprecated_placement,
7988
7989
  popoverScheme: deprecated_popoverScheme,
7989
7990
  portal: deprecated_portal = true,
@@ -7996,6 +7997,11 @@ const MenuButton = forwardRef(function MenuButton2(props, ref) {
7996
7997
  const [buttonElement, setButtonElement] = useState(null);
7997
7998
  const [menuElements, setChildMenuElements] = useState([]);
7998
7999
  const openRef = useRef(open);
8000
+ useEffect(() => {
8001
+ if (onOpen && open && !openRef.current) {
8002
+ onOpen();
8003
+ }
8004
+ }, [onOpen, open]);
7999
8005
  useEffect(() => {
8000
8006
  if (onClose && !open && openRef.current) {
8001
8007
  onClose();