From a97357d7b187b052660c05a78e37b9000732daaa Mon Sep 17 00:00:00 2001 From: sarah Date: Sun, 20 Oct 2024 23:52:38 +0500 Subject: [PATCH] Standalone popover is always open Change-Id: Ia139c332e6b76a29176e385676cef6b1ec667717 GitOrigin-RevId: e20b818491cbbb6ba278c7f51f528b08d72a1324 --- plasmicpkgs/react-aria/src/registerModal.tsx | 6 ++---- plasmicpkgs/react-aria/src/registerPopover.tsx | 15 +++++++-------- plasmicpkgs/react-aria/src/utils.ts | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/plasmicpkgs/react-aria/src/registerModal.tsx b/plasmicpkgs/react-aria/src/registerModal.tsx index a887bd0e53d..e9a1b40dfb4 100644 --- a/plasmicpkgs/react-aria/src/registerModal.tsx +++ b/plasmicpkgs/react-aria/src/registerModal.tsx @@ -56,9 +56,7 @@ export const BaseModal = forwardRef( const contextProps = React.useContext(PlasmicDialogTriggerContext); const isStandalone = !contextProps; const mergedProps = mergeProps(contextProps, rest, { - isOpen: isStandalone - ? (isSelected || isOpen) ?? false - : contextProps.isOpen, + isOpen: isStandalone ? isSelected || isOpen : contextProps.isOpen, }); setControlContextData?.({ @@ -181,7 +179,7 @@ export function registerModal( type: "boolean", editOnly: true, uncontrolledProp: "defaultOpen", - defaultValueHint: false, + defaultValueHint: true, defaultValue: true, hidden: hasParent, }, diff --git a/plasmicpkgs/react-aria/src/registerPopover.tsx b/plasmicpkgs/react-aria/src/registerPopover.tsx index 7e03972b5a5..cede1a29f28 100644 --- a/plasmicpkgs/react-aria/src/registerPopover.tsx +++ b/plasmicpkgs/react-aria/src/registerPopover.tsx @@ -1,8 +1,4 @@ -import { - PlasmicElement, - usePlasmicCanvasComponentInfo, - usePlasmicCanvasContext, -} from "@plasmicapp/host"; +import { PlasmicElement, usePlasmicCanvasContext } from "@plasmicapp/host"; import { mergeProps } from "@react-aria/utils"; import React from "react"; import { Popover, PopoverContext } from "react-aria-components"; @@ -35,8 +31,6 @@ export function BasePopover(props: BasePopoverProps) { const triggerRef = React.useRef(null); const isEditMode = !!usePlasmicCanvasContext(); - const { isSelected } = usePlasmicCanvasComponentInfo(props) ?? {}; - const mergedProps = mergeProps( { isOpen: context?.isOpen, @@ -55,7 +49,12 @@ export function BasePopover(props: BasePopoverProps) { ? { triggerRef, isNonModal: true, - isOpen: isSelected ?? false, + /** + * Always true, because we assume that popover is always going to be controlled by a parent like Select, Combobox, DialogTrigger, etc, and its only really standalone in component view + * In component view, we never want to start with an empty artboard, so isOpen has to be true + * */ + + isOpen: true, } : null ); diff --git a/plasmicpkgs/react-aria/src/utils.ts b/plasmicpkgs/react-aria/src/utils.ts index a7486a28c13..733941cd5c1 100644 --- a/plasmicpkgs/react-aria/src/utils.ts +++ b/plasmicpkgs/react-aria/src/utils.ts @@ -1,4 +1,4 @@ -import type { CodeComponentMeta } from "@plasmicapp/host"; +import { type CodeComponentMeta } from "@plasmicapp/host"; import registerComponent from "@plasmicapp/host/registerComponent"; import React from "react";