fix canceling tx on blur

pull/4456/head
yann300 9 months ago
parent 2cd7eb8ad0
commit 20996aa7e4
  1. 24
      libs/remix-ui/modal-dialog/src/lib/remix-ui-modal-dialog.tsx

@ -26,25 +26,25 @@ export const ModalDialog = (props: ModalDialogProps) => {
useEffect(() => {
calledHideFunctionOnce.current = props.hide
modal.current.focus()
}, [props.hide])
useEffect(() => {
function handleBlur(e) {
if (!e.currentTarget.contains(e.relatedTarget)) {
e.stopPropagation()
if (document.activeElement !== this) {
!window.testmode && handleHide()
if (props.cancelFn) props.cancelFn()
}
}
}
if (modal.current) {
modal.current.removeEventListener('blur', handleBlur)
modal.current.addEventListener('blur', handleBlur)
}
return () => {
modal.current && modal.current.removeEventListener('blur', handleBlur)
}
}, [modal.current])
}, [props.hide])
function handleBlur(e) {
if (!e.currentTarget.contains(e.relatedTarget)) {
e.stopPropagation()
if (document.activeElement !== this) {
!window.testmode && handleHide()
if (props.cancelFn) props.cancelFn()
}
}
}
const modalKeyEvent = (keyCode) => {
if (keyCode === 27) {

Loading…
Cancel
Save