-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix: Import collection modal closes when click on ENTER #3830
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,7 @@ const Modal = ({ | |
confirmText, | ||
cancelText, | ||
handleCancel, | ||
handleConfirm, | ||
handleConfirm = () => {}, | ||
children, | ||
confirmDisabled, | ||
hideCancel, | ||
|
@@ -92,7 +92,7 @@ const Modal = ({ | |
}; | ||
|
||
useFocusTrap(modalRef); | ||
|
||
const closeModal = (args) => { | ||
setIsClosing(true); | ||
setTimeout(() => handleCancel(args), closeModalFadeTimeout); | ||
|
@@ -103,7 +103,7 @@ const Modal = ({ | |
return () => { | ||
document.removeEventListener('keydown', handleKeydown); | ||
}; | ||
}, [disableEscapeKey, document]); | ||
}, [disableEscapeKey, document, handleConfirm]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i will have to move handleKeyDown to a useCallback function with handleConfirm, closeModal, disableEscKey as deps, before adding it as a dependency right? else, the useEffect will get called with each render? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
yes, that will be even better
yes, but at least it won't have any unexpected behaviors |
||
|
||
let classes = 'bruno-modal'; | ||
if (isClosing) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick check around the code will show that this was already optional and this change is not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i thought about just removing it initially, without adding a default value for the prop, it would have worked fine keypress "Enter" case, it is bounded by the if check, but no such condtional is there when is called from modal footer. @ramki-bruno
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined
foronClick
would be absolutely fine