Skip to content

Commit

Permalink
Replace expanded card close handle function so it doesnt close when u…
Browse files Browse the repository at this point in the history
…ploading image
  • Loading branch information
BaldissaraMatheus committed Dec 2, 2024
1 parent f89ce2e commit c1b0875
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions frontend/src/components/expanded-card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function ExpandedCard(props) {
);

let dialogRef;
let backdropRef;
let tagsInputRef;
let editorContainerRef;

Expand Down Expand Up @@ -358,9 +359,24 @@ function ExpandedCard(props) {
props.onClose();
}

function handleBackdropClick(e) {
if (e.target === backdropRef) {
handleDialogCancel();
}
}

return (
<Portal>
<div class="dialog-backdrop">
<div
class="dialog-backdrop"
onClick={handleBackdropClick}
onKeyDown={(e) =>
handleKeyDown(e, (event) => handleBackdropClick(event))
}
ref={(el) => {
backdropRef = el;
}}
>
<dialog
ref={(el) => {
dialogRef = el;
Expand All @@ -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}
>
<div class="dialog__body">
<header class="dialog__toolbar">
Expand Down Expand Up @@ -460,12 +477,8 @@ function ExpandedCard(props) {
</For>
</div>
<div class="dialog__content">
<style>
{stacksStyle}
</style>
<style>
{stacksEditorStyle}
</style>
<style>{stacksStyle}</style>
<style>{stacksEditorStyle}</style>
<div
id="editor-container"
autofocus
Expand Down

0 comments on commit c1b0875

Please sign in to comment.