From 712f0309e9d750bc98552dd114e4e0d77b2a8c28 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 3 Jul 2023 15:27:18 -0400 Subject: [PATCH] Simplify click-outside close widget logic --- shared/naturalcrit/codeEditor/codeEditor.jsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 86cf36104..cb787d59c 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -453,16 +453,8 @@ const CodeEditor = createClass({ }; }, handleMouseDown : function(e) { - let target = e.target; - let found = false; - while (target.parentElement) { - target = target.parentElement; - if(target.classList.contains('CodeMirror-linewidget')) { - found = true; - break; - } - } - if(!found) { + // Close open widgets if click outside of a widget + if(!e.target.matches('.CodeMirror-linewidget *')) { for (const widget of this.state.widgets) { this.state.widgetUtils.removeLineWidgets(widget); }