Skip to content

Commit

Permalink
chore: undo pr3307 (#3756)
Browse files Browse the repository at this point in the history
* chore: rollback pr3307

* chore(changeset): fix typo
  • Loading branch information
wingkwong authored Sep 14, 2024
1 parent 5517a05 commit 4c01d18
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 38 deletions.
6 changes: 6 additions & 0 deletions .changeset/fair-worms-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nextui-org/popover": patch
"@nextui-org/tooltip": patch
---

rollback PR3307. rescheduled to v2.5.0.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export const FloatingComponents: React.FC<{}> = () => {
content="Developers love Next.js"
isOpen={!isTablet}
placement="top"
shouldBlockScroll={false}
style={{
zIndex: 39,
}}
Expand Down
3 changes: 2 additions & 1 deletion packages/components/popover/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"@react-aria/utils": "3.24.1",
"@react-stately/overlays": "3.6.7",
"@react-types/button": "3.9.4",
"@react-types/overlays": "3.8.7"
"@react-types/overlays": "3.8.7",
"react-remove-scroll": "^2.5.6"
},
"devDependencies": {
"@nextui-org/card": "workspace:*",
Expand Down
41 changes: 24 additions & 17 deletions packages/components/popover/src/popover-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {HTMLMotionProps} from "framer-motion";

import {DOMAttributes, ReactNode, useMemo, useRef} from "react";
import {forwardRef} from "@nextui-org/system";
import {RemoveScroll} from "react-remove-scroll";
import {DismissButton} from "@react-aria/overlays";
import {TRANSITION_VARIANTS} from "@nextui-org/framer-utils";
import {m, domAnimation, LazyMotion} from "framer-motion";
Expand All @@ -23,10 +24,12 @@ const PopoverContent = forwardRef<"div", PopoverContentProps>((props, _) => {

const {
Component: OverlayComponent,
isOpen,
placement,
backdrop,
motionProps,
disableAnimation,
shouldBlockScroll,
getPopoverProps,
getDialogProps,
getBackdropProps,
Expand Down Expand Up @@ -79,23 +82,27 @@ const PopoverContent = forwardRef<"div", PopoverContentProps>((props, _) => {
);
}, [backdrop, disableAnimation, getBackdropProps]);

const contents = disableAnimation ? (
content
) : (
<LazyMotion features={domAnimation}>
<m.div
animate="enter"
exit="exit"
initial="initial"
style={{
...getTransformOrigins(placement === "center" ? "top" : placement),
}}
variants={TRANSITION_VARIANTS.scaleSpringOpacity}
{...motionProps}
>
{content}
</m.div>
</LazyMotion>
const contents = (
<RemoveScroll enabled={shouldBlockScroll && isOpen} removeScrollBar={false}>
{disableAnimation ? (
content
) : (
<LazyMotion features={domAnimation}>
<m.div
animate="enter"
exit="exit"
initial="initial"
style={{
...getTransformOrigins(placement === "center" ? "top" : placement),
}}
variants={TRANSITION_VARIANTS.scaleSpringOpacity}
{...motionProps}
>
{content}
</m.div>
</LazyMotion>
)}
</RemoveScroll>
);

return (
Expand Down
7 changes: 2 additions & 5 deletions packages/components/popover/src/use-popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {RefObject, Ref} from "react";
import {ReactRef, useDOMRef} from "@nextui-org/react-utils";
import {OverlayTriggerState, useOverlayTriggerState} from "@react-stately/overlays";
import {useFocusRing} from "@react-aria/focus";
import {useOverlayTrigger, usePreventScroll} from "@react-aria/overlays";
import {useOverlayTrigger} from "@react-aria/overlays";
import {OverlayTriggerProps} from "@react-types/overlays";
import {
HTMLNextUIProps,
Expand Down Expand Up @@ -298,10 +298,6 @@ export function usePopover(originalProps: UsePopoverProps) {
[slots, state.isOpen, classNames, underlayProps],
);

usePreventScroll({
isDisabled: !(shouldBlockScroll && state.isOpen),
});

return {
state,
Component,
Expand All @@ -316,6 +312,7 @@ export function usePopover(originalProps: UsePopoverProps) {
isOpen: state.isOpen,
onClose: state.close,
disableAnimation,
shouldBlockScroll,
backdrop: originalProps.backdrop ?? "transparent",
motionProps,
getBackdropProps,
Expand Down
15 changes: 1 addition & 14 deletions packages/components/tooltip/src/use-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import {ReactNode, Ref, useId, useImperativeHandle} from "react";
import {useTooltipTriggerState} from "@react-stately/tooltip";
import {mergeProps} from "@react-aria/utils";
import {useTooltip as useReactAriaTooltip, useTooltipTrigger} from "@react-aria/tooltip";
import {
useOverlayPosition,
useOverlay,
AriaOverlayProps,
usePreventScroll,
} from "@react-aria/overlays";
import {useOverlayPosition, useOverlay, AriaOverlayProps} from "@react-aria/overlays";
import {
HTMLNextUIProps,
mapPropsVariants,
Expand Down Expand Up @@ -87,11 +82,6 @@ interface Props extends Omit<HTMLNextUIProps, "content"> {
* ```
*/
classNames?: SlotsToClasses<"base" | "arrow" | "content">;
/**
* Whether to block scrolling outside the tooltip.
* @default true
*/
shouldBlockScroll?: boolean;
}

export type UseTooltipProps = Props &
Expand Down Expand Up @@ -133,7 +123,6 @@ export function useTooltip(originalProps: UseTooltipProps) {
onClose,
motionProps,
classNames,
shouldBlockScroll = true,
...otherProps
} = props;

Expand Down Expand Up @@ -169,8 +158,6 @@ export function useTooltip(originalProps: UseTooltipProps) {
createDOMRef(overlayRef),
);

usePreventScroll({isDisabled: !(shouldBlockScroll && isOpen)});

const {triggerProps, tooltipProps: triggerTooltipProps} = useTooltipTrigger(
{
isDisabled,
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4c01d18

Please sign in to comment.