Skip to content

Commit c1b0875

Browse files
Replace expanded card close handle function so it doesnt close when uploading image
1 parent f89ce2e commit c1b0875

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

frontend/src/components/expanded-card.jsx

+21-8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function ExpandedCard(props) {
5858
);
5959

6060
let dialogRef;
61+
let backdropRef;
6162
let tagsInputRef;
6263
let editorContainerRef;
6364

@@ -358,9 +359,24 @@ function ExpandedCard(props) {
358359
props.onClose();
359360
}
360361

362+
function handleBackdropClick(e) {
363+
if (e.target === backdropRef) {
364+
handleDialogCancel();
365+
}
366+
}
367+
361368
return (
362369
<Portal>
363-
<div class="dialog-backdrop">
370+
<div
371+
class="dialog-backdrop"
372+
onClick={handleBackdropClick}
373+
onKeyDown={(e) =>
374+
handleKeyDown(e, (event) => handleBackdropClick(event))
375+
}
376+
ref={(el) => {
377+
backdropRef = el;
378+
}}
379+
>
364380
<dialog
365381
ref={(el) => {
366382
dialogRef = el;
@@ -370,7 +386,8 @@ function ExpandedCard(props) {
370386
handleKeyDown(e, (event) => event.stopPropagation())
371387
}
372388
onCancel={handleDialogCancel}
373-
use:clickOutside={handleDialogCancel}
389+
// TODO Doesn't work rn because it can be triggered by clicking image upload confirm button. Try again when new editor is implemented
390+
// use:clickOutside={handleDialogCancel}
374391
>
375392
<div class="dialog__body">
376393
<header class="dialog__toolbar">
@@ -460,12 +477,8 @@ function ExpandedCard(props) {
460477
</For>
461478
</div>
462479
<div class="dialog__content">
463-
<style>
464-
{stacksStyle}
465-
</style>
466-
<style>
467-
{stacksEditorStyle}
468-
</style>
480+
<style>{stacksStyle}</style>
481+
<style>{stacksEditorStyle}</style>
469482
<div
470483
id="editor-container"
471484
autofocus

0 commit comments

Comments
 (0)