From 6b30fd02b7745449329ae2c17318fe68f191fd18 Mon Sep 17 00:00:00 2001 From: Giancarlo Sierra Date: Mon, 2 Oct 2023 14:51:27 -0700 Subject: [PATCH] Control background click mouse events (#523) Mouse click, down, and up events will be handled to avoid closing the modal by accident. This avoids accidents when highlighting text and dragging the mouse cursor outside of the modal area (into the background). Solves #518 This also allows the user to escape closing the modal by dragging the mouse click back into the modal content area. Co-authored-by: Chris Sainty --- src/Blazored.Modal/BlazoredModalInstance.razor | 8 +++++--- src/Blazored.Modal/BlazoredModalInstance.razor.cs | 13 ++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Blazored.Modal/BlazoredModalInstance.razor b/src/Blazored.Modal/BlazoredModalInstance.razor index 721cae30..aa9f7d08 100644 --- a/src/Blazored.Modal/BlazoredModalInstance.razor +++ b/src/Blazored.Modal/BlazoredModalInstance.razor @@ -7,11 +7,13 @@ else {
+ @ref="_modalReference" + @onmousedown="ListenToBackgroundClick" + @onmouseup="HandleBackgroundClick" + @onclick="StopListeningToBackgroundClick"> -