Skip to content

Commit 29c0b7e

Browse files
committed
feat(web): close-popup-on-outside-click
1 parent 8bdf19b commit 29c0b7e

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

web/src/components/ClaimPnkButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const ClaimPnkButton: React.FC = () => {
5151
const { request } = await simulatePnkFaucet(wagmiConfig, {
5252
functionName: "request",
5353
});
54-
if (walletClient) {
54+
if (walletClient && publicClient) {
5555
wrapWithToast(async () => await walletClient.writeContract(request), publicClient)
5656
.finally(() => {
5757
setIsSending(false);

web/src/components/Popup/index.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,14 @@ const Popup: React.FC<PopupProps & IPopup> = ({
236236
break;
237237
}
238238

239+
const closePopup = () => {
240+
setIsOpen(false);
241+
resetValue();
242+
};
243+
239244
return (
240-
<Overlay>
241-
<Container ref={containerRef}>
245+
<Overlay onClick={closePopup}>
246+
<Container ref={containerRef} onClick={(e) => e.stopPropagation()}>
242247
{popupType === PopupType.SWAP_SUCCESS && (
243248
<SVGContainer>
244249
<CloseIcon onClick={() => setIsOpen(false)} />
@@ -259,8 +264,7 @@ const Popup: React.FC<PopupProps & IPopup> = ({
259264
variant="secondary"
260265
text={popupType === PopupType.DISPUTE_CREATED ? "Check the case" : "Close"}
261266
onClick={() => {
262-
setIsOpen(false);
263-
resetValue();
267+
closePopup();
264268
if (popupType === PopupType.DISPUTE_CREATED) {
265269
const { disputeId } = props as IDisputeCreated;
266270
navigate(`/cases/${disputeId}`);

web/src/pages/Cases/CaseDetails/Appeal/Classic/Fund.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ const Fund: React.FC<IFund> = ({ amount, setAmount, setIsOpen }) => {
137137
if (fundAppeal && fundAppealConfig && publicClient) {
138138
setIsSending(true);
139139
wrapWithToast(async () => await fundAppeal(fundAppealConfig.request), publicClient)
140-
.then((res) => {
141-
res.status && setIsOpen(true);
142-
})
140+
.then((res) => setIsOpen(res.status))
143141
.finally(() => {
144142
setIsSending(false);
145143
});

web/src/pages/Cases/CaseDetails/Evidence/SubmitEvidenceModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const SubmitEvidenceModal: React.FC<{
9191
}, [publicClient, wagmiConfig, walletClient, close, evidenceGroup, file, message, setIsSending, uploadFile]);
9292

9393
return (
94-
<StyledModal {...{ isOpen }}>
94+
<StyledModal {...{ isOpen }} shouldCloseOnEsc shouldCloseOnOverlayClick onRequestClose={close}>
9595
<h1>Submit New Evidence</h1>
9696
<StyledTextArea value={message} onChange={(e) => setMessage(e.target.value)} placeholder="Your Arguments" />
9797
<StyledFileUploader callback={(file: File) => setFile(file)} />

web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({
127127
if (setStakeConfig && publicClient) {
128128
setIsSending(true);
129129
wrapWithToast(async () => await setStake(setStakeConfig.request), publicClient)
130-
.then((res) => res.status && setIsPopupOpen(true))
130+
.then((res) => setIsPopupOpen(res.status))
131131
.finally(() => {
132132
setIsSending(false);
133133
});

0 commit comments

Comments
 (0)