Repository: mito-ds/mito (language: python)

Issue:
Clicking multiple times quickly on a cell to reference it in a formula deletes the formulas
**Describe the bug**
Clicking multiple times quickly on a cell to reference it in a formula deletes the formulas

**To Reproduce**
Steps to reproduce the behavior:
1. Create a new column
2. Open the cell editor
3. Click a bunch of times quickly click on a cell
4. Notice the formula disappears. 


This happens on Chrome and Safari on Mac. 


https://user-images.githubusercontent.com/18709905/215140561-c4f40f81-c70d-44c2-a539-7e69cb2f854c.mov




Discussion / hints:

Fix patch:
diff --git a/mitosheet/src/mito/components/endo/EndoGrid.tsx b/mitosheet/src/mito/components/endo/EndoGrid.tsx
index 6978199cd..9f8c4cf36 100644
--- a/mitosheet/src/mito/components/endo/EndoGrid.tsx
+++ b/mitosheet/src/mito/components/endo/EndoGrid.tsx
@@ -544,6 +544,9 @@ function EndoGrid(props: {
 
     // On double click, open the cell editor on this cell
     const onDoubleClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
+        if (editorState !== undefined) {
+            return;
+        }
         const {rowIndex, columnIndex} = getIndexesFromMouseEvent(e);
         // Don't open for headers
         if ((rowIndex === undefined || columnIndex === undefined) || getIsHeader(rowIndex, columnIndex)) {


Test patch:
diff --git a/tests/streamlit_ui_tests/grid/set_column_formula_tests.spec.ts b/tests/streamlit_ui_tests/grid/set_column_formula_tests.spec.ts
index fcfce3abd..62e1f008e 100644
--- a/tests/streamlit_ui_tests/grid/set_column_formula_tests.spec.ts
+++ b/tests/streamlit_ui_tests/grid/set_column_formula_tests.spec.ts
@@ -143,6 +143,21 @@ test('Reference cell in previous row by clicking on it', async ({ page }) => {
     expect(cellValues).toEqual(['0', '1', '4', '7']);
 });
 
+test('Double clicking on cell while cell editor is open does not close cell editor', async ({ page }) => {
+    const columnHeader = 'Column4';
+
+    const mito = await getMitoFrameWithTestCSV(page);
+    await createNewColumn(page, mito, 3, columnHeader);
+
+    const cell = await getCellAtRowIndexAndColumnName(mito, 0, columnHeader);
+    await cell.dblclick();
+    await mito.getByRole('textbox').fill('=');
+
+    const otherCell = await getCellAtRowIndexAndColumnName(mito, 0, 'Column1');
+    await otherCell.dblclick();
+    await expect(mito.locator('#cell-editor-input')).toHaveValue('=Column10');
+});
+
 test('Use arrow keys to select cell', async ({ page }) => {
     const columnHeader = 'Column4';