Skip to content

Commit

Permalink
Standalone popover is always open
Browse files Browse the repository at this point in the history
Change-Id: Ia139c332e6b76a29176e385676cef6b1ec667717
GitOrigin-RevId: e20b818491cbbb6ba278c7f51f528b08d72a1324
  • Loading branch information
sarahsga authored and actions-user committed Oct 28, 2024
1 parent 5a75cce commit a97357d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
6 changes: 2 additions & 4 deletions plasmicpkgs/react-aria/src/registerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ export const BaseModal = forwardRef<BaseModalActions, BaseModalProps>(
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?.({
Expand Down Expand Up @@ -181,7 +179,7 @@ export function registerModal(
type: "boolean",
editOnly: true,
uncontrolledProp: "defaultOpen",
defaultValueHint: false,
defaultValueHint: true,
defaultValue: true,
hidden: hasParent,
},
Expand Down
15 changes: 7 additions & 8 deletions plasmicpkgs/react-aria/src/registerPopover.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -35,8 +31,6 @@ export function BasePopover(props: BasePopoverProps) {
const triggerRef = React.useRef<any>(null);
const isEditMode = !!usePlasmicCanvasContext();

const { isSelected } = usePlasmicCanvasComponentInfo(props) ?? {};

const mergedProps = mergeProps(
{
isOpen: context?.isOpen,
Expand All @@ -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
);
Expand Down
2 changes: 1 addition & 1 deletion plasmicpkgs/react-aria/src/utils.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down

0 comments on commit a97357d

Please sign in to comment.