Skip to content

Commit

Permalink
Remove keepMounted prop in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Dec 24, 2024
1 parent 5c37994 commit a326ad8
Show file tree
Hide file tree
Showing 34 changed files with 113 additions and 123 deletions.
2 changes: 1 addition & 1 deletion docs/reference/generated/menu-portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"keepMounted": {
"type": "boolean",
"default": "false",
"description": "Whether to keep the portal mounted in the DOM while the popup is hidden.\nwhen the popup is closed."
"description": "Whether to keep the portal mounted in the DOM while the popup is hidden."
}
},
"dataAttributes": {},
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/generated/popover-portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"keepMounted": {
"type": "boolean",
"default": "false",
"description": "Whether to keep the portal mounted in the DOM while the popup is hidden.\nwhen the popup is closed."
"description": "Whether to keep the portal mounted in the DOM while the popup is hidden."
}
},
"dataAttributes": {},
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/generated/preview-card-portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"keepMounted": {
"type": "boolean",
"default": "false",
"description": "Whether to keep the portal mounted in the DOM while the popup is hidden.\nwhen the popup is closed."
"description": "Whether to keep the portal mounted in the DOM while the popup is hidden."
}
},
"dataAttributes": {},
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/generated/tooltip-portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"keepMounted": {
"type": "boolean",
"default": "false",
"description": "Whether to keep the portal mounted in the DOM while the popup is hidden.\nwhen the popup is closed."
"description": "Whether to keep the portal mounted in the DOM while the popup is hidden."
}
},
"dataAttributes": {},
Expand Down
33 changes: 11 additions & 22 deletions docs/src/app/(private)/experiments/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,11 @@ function CssTransitionDialogDemo({ keepMounted, modal, dismissible }: DemoProps)
Open with CSS transition
</Dialog.Trigger>

<Dialog.Backdrop
keepMounted={keepMounted}
className={clsx(classes.backdrop, classes.withTransitions)}
/>

<Dialog.Portal>
<Dialog.Popup
keepMounted={keepMounted}
className={clsx(classes.dialog, classes.withTransitions)}
>
<Dialog.Portal keepMounted={keepMounted}>
<Dialog.Backdrop
className={clsx(classes.backdrop, classes.withTransitions)}
/>
<Dialog.Popup className={clsx(classes.dialog, classes.withTransitions)}>
{renderContent(
'Dialog with CSS transitions',
NESTED_DIALOGS,
Expand All @@ -106,16 +101,11 @@ function CssAnimationDialogDemo({ keepMounted, modal, dismissible }: DemoProps)
Open with CSS animation
</Dialog.Trigger>

<Dialog.Backdrop
keepMounted={keepMounted}
className={clsx(classes.backdrop, classes.withAnimations)}
/>

<Dialog.Portal>
<Dialog.Popup
keepMounted={keepMounted}
className={clsx(classes.dialog, classes.withAnimations)}
>
<Dialog.Portal keepMounted={keepMounted}>
<Dialog.Backdrop
className={clsx(classes.backdrop, classes.withAnimations)}
/>
<Dialog.Popup className={clsx(classes.dialog, classes.withAnimations)}>
{renderContent(
'Dialog with CSS animations',
NESTED_DIALOGS,
Expand Down Expand Up @@ -147,9 +137,8 @@ function ReactSpringDialogDemo({ keepMounted, modal, dismissible }: DemoProps) {
/>

<ReactSpringTransition open={open}>
<Dialog.Portal>
<Dialog.Portal keepMounted={keepMounted}>
<Dialog.Popup
keepMounted={keepMounted}
className={`${classes.dialog} ${classes.withReactSpringTransition}`}
>
{renderContent(
Expand Down
18 changes: 4 additions & 14 deletions docs/src/app/(private)/experiments/menu-rtl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ export default function RtlPopover() {
<Popover.Trigger className={s.IconButton}>
<BellIcon aria-label="Notifications" className={s.Icon} />
</Popover.Trigger>
<Popover.Portal>
<Popover.Positioner
sideOffset={12}
dir={DIR}
side="inline-start"
keepMounted
>
<Popover.Portal keepMounted>
<Popover.Positioner sideOffset={12} dir={DIR} side="inline-start">
<Popover.Popup className={s.Popup}>
<Popover.Arrow className={s.Arrow}>
<ArrowSvg />
Expand All @@ -40,13 +35,8 @@ export default function RtlPopover() {
<Popover.Trigger className={s.IconButton}>
<BellIcon aria-label="Notifications" className={s.Icon} />
</Popover.Trigger>
<Popover.Portal>
<Popover.Positioner
sideOffset={12}
dir={DIR}
side="inline-end"
keepMounted
>
<Popover.Portal keepMounted>
<Popover.Positioner sideOffset={12} dir={DIR} side="inline-end">
<Popover.Popup className={s.Popup}>
<Popover.Arrow className={s.Arrow}>
<ArrowSvg />
Expand Down
20 changes: 12 additions & 8 deletions docs/src/app/(private)/experiments/popup-transform-origin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ function Popover({ side }: { side: Side }) {
<PopoverPrimitive.Trigger className={styles.Trigger}>
{side}
</PopoverPrimitive.Trigger>
<PopoverPrimitive.Positioner side={side} sideOffset={20}>
<PopoverPrimitive.Popup className={styles.Popup} />
</PopoverPrimitive.Positioner>
<PopoverPrimitive.Portal>
<PopoverPrimitive.Positioner side={side} sideOffset={20}>
<PopoverPrimitive.Popup className={styles.Popup} />
</PopoverPrimitive.Positioner>
</PopoverPrimitive.Portal>
</PopoverPrimitive.Root>
);
}
Expand All @@ -22,11 +24,13 @@ function PopoverWithArrow({ side }: { side: Side }) {
<PopoverPrimitive.Trigger className={styles.Trigger}>
{side}
</PopoverPrimitive.Trigger>
<PopoverPrimitive.Positioner side={side} sideOffset={20}>
<PopoverPrimitive.Popup className={styles.Popup}>
<PopoverPrimitive.Arrow className={styles.Arrow} />
</PopoverPrimitive.Popup>
</PopoverPrimitive.Positioner>
<PopoverPrimitive.Portal>
<PopoverPrimitive.Positioner side={side} sideOffset={20}>
<PopoverPrimitive.Popup className={styles.Popup}>
<PopoverPrimitive.Arrow className={styles.Arrow} />
</PopoverPrimitive.Popup>
</PopoverPrimitive.Positioner>
</PopoverPrimitive.Portal>
</PopoverPrimitive.Root>
);
}
Expand Down
14 changes: 7 additions & 7 deletions docs/src/app/(private)/experiments/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export default function TooltipTransitionExperiment() {
<Tooltip.Root>
<AnchorButton>Anchor</AnchorButton>
<Tooltip.Portal keepMounted>
<Tooltip.Positioner sideOffset={7} keepMounted>
<Tooltip.Positioner sideOffset={7}>
<TooltipPopup data-type="css-animation-keep-mounted">
Tooltip
</TooltipPopup>
Expand All @@ -237,7 +237,7 @@ export default function TooltipTransitionExperiment() {
<Tooltip.Root>
<AnchorButton>Anchor</AnchorButton>
<Tooltip.Portal keepMounted>
<Tooltip.Positioner sideOffset={7} keepMounted>
<Tooltip.Positioner sideOffset={7}>
<TooltipPopup data-type="css-animation-keep-mounted">
Tooltip
</TooltipPopup>
Expand All @@ -250,7 +250,7 @@ export default function TooltipTransitionExperiment() {
<Tooltip.Root>
<AnchorButton>Anchor</AnchorButton>
<Tooltip.Portal keepMounted>
<Tooltip.Positioner sideOffset={7} keepMounted>
<Tooltip.Positioner sideOffset={7}>
<TooltipPopup data-type="css-animation-keep-mounted">
Tooltip
</TooltipPopup>
Expand All @@ -264,7 +264,7 @@ export default function TooltipTransitionExperiment() {
<Tooltip.Root>
<AnchorButton>Anchor</AnchorButton>
<Tooltip.Portal keepMounted>
<Tooltip.Positioner sideOffset={7} keepMounted>
<Tooltip.Positioner sideOffset={7}>
<TooltipPopup data-type="css-transition-keep-mounted">
Tooltip
</TooltipPopup>
Expand All @@ -274,7 +274,7 @@ export default function TooltipTransitionExperiment() {
<Tooltip.Root>
<AnchorButton>Anchor</AnchorButton>
<Tooltip.Portal keepMounted>
<Tooltip.Positioner sideOffset={7} keepMounted>
<Tooltip.Positioner sideOffset={7}>
<TooltipPopup data-type="css-transition-keep-mounted">
Tooltip
</TooltipPopup>
Expand All @@ -287,7 +287,7 @@ export default function TooltipTransitionExperiment() {
<Tooltip.Root>
<AnchorButton>Anchor</AnchorButton>
<Tooltip.Portal keepMounted>
<Tooltip.Positioner sideOffset={7} keepMounted>
<Tooltip.Positioner sideOffset={7}>
<TooltipPopup data-type="css-transition-keep-mounted">
Tooltip
</TooltipPopup>
Expand All @@ -311,7 +311,7 @@ function FramerMotion() {
<AnimatePresence>
{isOpen && (
<Tooltip.Portal keepMounted>
<Tooltip.Positioner keepMounted sideOffset={7}>
<Tooltip.Positioner sideOffset={7}>
<TooltipPopup
data-type="framer-motion"
render={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function ExampleDialog() {
return (
<Dialog.Root>
<Dialog.Trigger className={styles.Button}>View notifications</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Portal keepMounted>
<Dialog.Backdrop className={styles.Backdrop} />
<Dialog.Popup className={styles.Popup}>
<Dialog.Title className={styles.Title}>Notifications</Dialog.Title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ describe('<AlertDialog.Popup />', () => {
render: (node) => {
return render(
<AlertDialog.Root open>
<AlertDialog.Backdrop />
<AlertDialog.Portal>{node}</AlertDialog.Portal>
<AlertDialog.Portal>
<AlertDialog.Backdrop />
{node}
</AlertDialog.Portal>
</AlertDialog.Root>,
);
},
Expand Down
4 changes: 0 additions & 4 deletions packages/react/src/alert-dialog/popup/AlertDialogPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ const AlertDialogPopup = React.forwardRef(function AlertDialogPopup(
customStyleHookMapping,
});

if (!mounted) {
return null;
}

return (
<React.Fragment>
{mounted && modal && <InternalBackdrop />}
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/alert-dialog/portal/AlertDialogPortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function AlertDialogPortal(props: AlertDialogPortal.Props) {
}

return (
<AlertDialogPortalContext.Provider value>
<FloatingPortal root={container}>{children}</FloatingPortal>;
<AlertDialogPortalContext.Provider value={keepMounted}>
<FloatingPortal root={container}>{children}</FloatingPortal>
</AlertDialogPortalContext.Provider>
);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/dialog/popup/DialogPopup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('<Dialog.Popup />', () => {
it(`should ${!expectedIsMounted ? 'not ' : ''}keep the dialog mounted when keepMounted=${keepMounted}`, async () => {
const { queryByRole } = await render(
<Dialog.Root open={false} modal={false}>
<Dialog.Portal keepMounted>
<Dialog.Popup keepMounted={keepMounted} />
<Dialog.Portal keepMounted={keepMounted}>
<Dialog.Popup />
</Dialog.Portal>
</Dialog.Root>,
);
Expand Down
4 changes: 0 additions & 4 deletions packages/react/src/dialog/popup/DialogPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ const DialogPopup = React.forwardRef(function DialogPopup(
customStyleHookMapping,
});

if (!mounted) {
return null;
}

return (
<React.Fragment>
{mounted && modal && <InternalBackdrop />}
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/dialog/portal/DialogPortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ function DialogPortal(props: DialogPortal.Props) {
}

return (
<DialogPortalContext.Provider value>
<FloatingPortal root={container}>{children}</FloatingPortal>;
<DialogPortalContext.Provider value={keepMounted}>
<FloatingPortal root={container}>{children}</FloatingPortal>
</DialogPortalContext.Provider>
);
}
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/dialog/root/DialogRoot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ describe('<Dialog.Root />', () => {
className="animation-test-popup"
data-testid="popup"
onAnimationEnd={notifyAnimationFinished}
keepMounted
/>
</Dialog.Portal>
</Dialog.Root>
Expand Down Expand Up @@ -399,8 +398,8 @@ describe('<Dialog.Root />', () => {
<Dialog.Root open modal={false}>
{/* eslint-disable-next-line react/no-danger */}
<style dangerouslySetInnerHTML={{ __html: css }} />
<Dialog.Portal>
<Dialog.Popup className="dialog" onTransitionEnd={notifyTransitionEnd} keepMounted />
<Dialog.Portal keepMounted>
<Dialog.Popup className="dialog" onTransitionEnd={notifyTransitionEnd} />
</Dialog.Portal>
</Dialog.Root>,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ describe('<Menu.CheckboxItem />', () => {
<Menu.Root modal={false}>
<Menu.Trigger>Open</Menu.Trigger>
<Menu.Portal keepMounted>
<Menu.Positioner keepMounted>
<Menu.Positioner>
<Menu.Popup>
<Menu.CheckboxItem>Item</Menu.CheckboxItem>
</Menu.Popup>
Expand Down
4 changes: 1 addition & 3 deletions packages/react/src/menu/portal/MenuPortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function MenuPortal(props: MenuPortal.Props) {

return (
<MenuPortalContext.Provider value={keepMounted}>
<FloatingPortal root={container}>{children}</FloatingPortal>;
<FloatingPortal root={container}>{children}</FloatingPortal>
</MenuPortalContext.Provider>
);
}
Expand All @@ -34,7 +34,6 @@ namespace MenuPortal {
children?: React.ReactNode;
/**
* Whether to keep the portal mounted in the DOM while the popup is hidden.
* when the popup is closed.
* @default false
*/
keepMounted?: boolean;
Expand All @@ -60,7 +59,6 @@ MenuPortal.propTypes /* remove-proptypes */ = {
container: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([HTMLElementType, refType]),
/**
* Whether to keep the portal mounted in the DOM while the popup is hidden.
* when the popup is closed.
* @default false
*/
keepMounted: PropTypes.bool,
Expand Down
8 changes: 5 additions & 3 deletions packages/react/src/menu/positioner/MenuPositioner.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ describe('<Menu.Positioner />', () => {
render: (node) => {
return render(
<FloatingTree>
<MenuRootContext.Provider value={testRootContext}>{node}</MenuRootContext.Provider>
<MenuRootContext.Provider value={testRootContext}>
<Menu.Portal>{node}</Menu.Portal>
</MenuRootContext.Provider>
</FloatingTree>,
);
},
Expand Down Expand Up @@ -248,7 +250,7 @@ describe('<Menu.Positioner />', () => {
<Menu.Root modal={false}>
<Menu.Trigger>Toggle</Menu.Trigger>
<Menu.Portal keepMounted>
<Menu.Positioner keepMounted>
<Menu.Positioner>
<Menu.Popup>
<Menu.Item>1</Menu.Item>
<Menu.Item>2</Menu.Item>
Expand Down Expand Up @@ -278,7 +280,7 @@ describe('<Menu.Positioner />', () => {
<Menu.Root modal={false}>
<Menu.Trigger>Toggle</Menu.Trigger>
<Menu.Portal keepMounted={false}>
<Menu.Positioner keepMounted={false}>
<Menu.Positioner>
<Menu.Popup>
<Menu.Item>1</Menu.Item>
<Menu.Item>2</Menu.Item>
Expand Down
Loading

0 comments on commit a326ad8

Please sign in to comment.