Skip to content

Commit

Permalink
- Click outside to close modal now only reacts to onMouseDown.
Browse files Browse the repository at this point in the history
# Use case

User presses mouse button inside modal, then moves pointer outside of modal and releases the mouse button.
The click is registered as outside the modal and closes it. Not very nice!

Now it uses onMouseDown instead of onClick, which requires the mouse down event to come from outside of modal.
  • Loading branch information
mattias800 committed Aug 20, 2024
1 parent 7b63f30 commit 622a5e2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/modal/src/dialog/UseDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function useDialog<TProps, TPromiseResolve = void>(
() => (
<DialogContext.Provider value={{ resolve, reject }}>
<dialog
onClick={
onMouseDown={
options.disableCloseOnClickOutside ? undefined : () => reject()
}
ref={currentRef}
Expand All @@ -132,7 +132,7 @@ export function useDialog<TProps, TPromiseResolve = void>(
<div
style={options.contentWrapperStyle}
className={options.contentWrapperClassName}
onClick={
onMouseDown={
options.disableCloseOnClickOutside
? undefined
: (ev) => ev.stopPropagation()
Expand Down

0 comments on commit 622a5e2

Please sign in to comment.