Skip to content

Commit

Permalink
Merge pull request #289 from reservoirprotocol/pedro/relay-5849-preve…
Browse files Browse the repository at this point in the history
…nt-trade-details-modal-from-closing-when-submitting-tx

Fix pointer down on dynamic elements causing swap modal to close
  • Loading branch information
pedromcunha authored Sep 24, 2024
2 parents 1e9fa5a + 49cd085 commit 298600f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/chilled-lies-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@reservoir0x/relay-kit-ui': patch
---

Fix swap modal closing when dynamic embedded wallet tx modal is prompted and clicked on
8 changes: 7 additions & 1 deletion packages/ui/src/components/common/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ type ModalProps = {
}

export const Modal: FC<
ComponentPropsWithoutRef<typeof DialogRoot> & ModalProps
ComponentPropsWithoutRef<typeof DialogRoot> &
ModalProps &
Pick<
ComponentPropsWithoutRef<typeof AnimatedContent>,
'onPointerDownOutside'
>
> = ({ trigger, css, showCloseButton = true, children, ...props }) => {
return (
<DialogRoot modal={true} {...props}>
Expand Down Expand Up @@ -48,6 +53,7 @@ export const Modal: FC<
padding: '4',
...css
}}
onPointerDownOutside={props.onPointerDownOutside}
>
{showCloseButton ? (
<DialogClose
Expand Down
12 changes: 12 additions & 0 deletions packages/ui/src/components/common/TransactionModal/SwapModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,18 @@ const InnerSwapModal: FC<InnerSwapModalProps> = ({
maxWidth: '412px !important'
}}
showCloseButton={isReviewQuoteStep}
onPointerDownOutside={(e) => {
const dynamicModalElements = Array.from(
document.querySelectorAll('#dynamic-send-transaction')
)
const clickedInsideDynamicModal = dynamicModalElements.some((el) =>
e.target ? el.contains(e.target as Node) : false
)

if (clickedInsideDynamicModal && dynamicModalElements.length > 0) {
e.preventDefault()
}
}}
>
<Flex
direction="column"
Expand Down

0 comments on commit 298600f

Please sign in to comment.