Prevent just a pointerdown on modal close button from closing dialog.#19603
Open
johndoknjas wants to merge 4 commits intolichess-org:masterfrom
Open
Prevent just a pointerdown on modal close button from closing dialog.#19603johndoknjas wants to merge 4 commits intolichess-org:masterfrom
johndoknjas wants to merge 4 commits intolichess-org:masterfrom
Conversation
ornicar
reviewed
Feb 24, 2026
ui/lib/src/view/dialog.ts
Outdated
| if (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) | ||
| if ( | ||
| (e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom) && | ||
| !dialog.contains(e.target as Node | null) // close button could be positioned outside the dialog |
Collaborator
There was a problem hiding this comment.
do we still need the X/Y position checks then?
Contributor
Author
There was a problem hiding this comment.
@ornicar Tested on Chrome & Safari (Mac) and it seems fine to remove them. I don't know enough about modal dialogs to be sure there aren't any edge cases where it'd make a difference though. @jonbgamble any thoughts on this?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To see the current behaviour, open a modal dialog and press down on the close button in its top-right area. This section of the close button is outside the dialog rectangle, so the standard modal behaviour applies (pointerdown outside => close dialog). This is slightly unexpected behaviour though, as it behaves differently from if we press down on the close button in say its bottom-left area.
The motivation came from trying to avoid the resulting behaviour of this use case: