From b5f780029432b8be6747550b332ff418ac8f28d8 Mon Sep 17 00:00:00 2001 From: en Date: Mon, 10 Feb 2025 10:57:34 +0100 Subject: [PATCH] fix(feed): use portals for profile section popups Fix #221 --- src/components/ProfileSection.tsx | 100 +++++++++++++++++------------- src/components/Zap.tsx | 6 +- 2 files changed, 60 insertions(+), 46 deletions(-) diff --git a/src/components/ProfileSection.tsx b/src/components/ProfileSection.tsx index 1ef0b6e..4f4d7b4 100644 --- a/src/components/ProfileSection.tsx +++ b/src/components/ProfileSection.tsx @@ -28,6 +28,7 @@ import { ZapPopUp } from './Zap' import placeholder from '../assets/img/DEGMods Placeholder Img.png' import { NDKEvent, NDKSubscriptionCacheUsage } from '@nostr-dev-kit/ndk' import { useProfile } from 'hooks/useProfile' +import { createPortal } from 'react-dom' type Props = { pubkey: string @@ -250,15 +251,6 @@ export const ProfileQRButtonWithPopUp = ({ useBodyScrollDisable(isOpen) - const onQrCodeClicked = async () => { - const href = `https://njump.me/${nprofile}` - const a = document.createElement('a') - a.href = href - a.target = '_blank' // Open in a new tab - a.rel = 'noopener noreferrer' // Recommended for security reasons - a.click() - } - return ( <>
{isOpen && ( -
-
-
-
-
-
-

Nostr Address

-
-
setIsOpen(false)} - > - - - -
-
-
- -
+ setIsOpen(false)} + /> + )} + + ) +} +interface ProfileQRPopupProps { + nprofile: string + handleClose: () => void +} + +const ProfileQRPopup = ({ nprofile, handleClose }: ProfileQRPopupProps) => { + const onQrCodeClicked = async () => { + const href = `https://njump.me/${nprofile}` + const a = document.createElement('a') + a.href = href + a.target = '_blank' // Open in a new tab + a.rel = 'noopener noreferrer' // Recommended for security reasons + a.click() + } + + return createPortal( +
+
+
+
+
+
+

Nostr Address

+
+ + + +
+
+
+
- )} - +
+
, + document.body ) } diff --git a/src/components/Zap.tsx b/src/components/Zap.tsx index 376397c..f95863b 100644 --- a/src/components/Zap.tsx +++ b/src/components/Zap.tsx @@ -27,6 +27,7 @@ import { } from '../utils' import { LoadingSpinner } from './LoadingSpinner' import { FALLBACK_PROFILE_IMAGE } from 'constants.ts' +import { createPortal } from 'react-dom' type PresetAmountProps = { label: string @@ -436,7 +437,7 @@ export const ZapPopUp = ({ } }, [notCloseAfterZap, handleClose]) - return ( + return createPortal( <> {isLoading && }
@@ -513,7 +514,8 @@ export const ZapPopUp = ({
- + , + document.body ) }