From 6c3026c4536ab24ba40a47004dd084d3bc15b96c Mon Sep 17 00:00:00 2001 From: Matheus Baldissara Date: Sun, 1 Dec 2024 23:58:15 -0300 Subject: [PATCH] Replace expanded card close handle function so it doesnt close when uploading image --- frontend/src/components/expanded-card.jsx | 29 ++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/expanded-card.jsx b/frontend/src/components/expanded-card.jsx index 5ab7c2b..73f2f05 100644 --- a/frontend/src/components/expanded-card.jsx +++ b/frontend/src/components/expanded-card.jsx @@ -58,6 +58,7 @@ function ExpandedCard(props) { ); let dialogRef; + let backdropRef; let tagsInputRef; let editorContainerRef; @@ -358,9 +359,24 @@ function ExpandedCard(props) { props.onClose(); } + function handleBackdropClick(e) { + if (e.target === backdropRef) { + handleDialogCancel(); + } + } + return ( -
+
+ handleKeyDown(e, (event) => handleBackdropClick(event)) + } + ref={(el) => { + backdropRef = el; + }} + > { dialogRef = el; @@ -370,7 +386,8 @@ function ExpandedCard(props) { handleKeyDown(e, (event) => event.stopPropagation()) } onCancel={handleDialogCancel} - use:clickOutside={handleDialogCancel} + // TODO Doesn't work rn because it can be triggered by clicking image upload confirm button. Try again when new editor is implemented + // use:clickOutside={handleDialogCancel} >
@@ -460,12 +477,8 @@ function ExpandedCard(props) {
- - + +