Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace expanded card close handle function so it doesnt close when uploading image #138

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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