From 5af8ee71aa9d35d594f4777f2049f3c8a70a7dbd Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 14 Aug 2023 16:38:21 -0700 Subject: [PATCH] Fix clicking outside of modals to dismiss them Co-authored-by: Mikayla --- crates/workspace/src/workspace.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index f875c71fe6..60488d04cf 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -3760,20 +3760,19 @@ impl View for Workspace { ) })) .with_children(self.modal.as_ref().map(|modal| { + // Prevent clicks within the modal from falling + // through to the rest of the workspace. enum ModalBackground {} MouseEventHandler::::new( 0, cx, - |_, cx| { - ChildView::new(modal.view.as_any(), cx) - .contained() - .with_style(theme.workspace.modal) - .aligned() - .top() - }, + |_, cx| ChildView::new(modal.view.as_any(), cx), ) .on_click(MouseButton::Left, |_, _, _| {}) - // Consume click events to stop focus dropping through + .contained() + .with_style(theme.workspace.modal) + .aligned() + .top() })) .with_children(self.render_notifications(&theme.workspace, cx)), ))