From fe846d306869ed0ceea98cfde879fe4b6c55bac8 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Mon, 14 Aug 2023 18:06:01 -0400 Subject: [PATCH] (core) allow copying errors from regular cell editor Summary: There was already some support for copying errors from the detached/expanded formula editor. This adds support for copying errors in the regular cell editor. Getting error details is now done only by clicking on the expand icon - previously you could click on the error text itself. A few unrelated test changes are made for exact-pixel checks that were often out by approx 1 pixel on my machine. Test Plan: Updated tests. Tested copying/pasting manually. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D4002 --- app/client/widgets/FormulaEditor.ts | 27 ++++++++------------------- app/client/widgets/TextEditor.css | 1 - 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/app/client/widgets/FormulaEditor.ts b/app/client/widgets/FormulaEditor.ts index f8e8b0d2..c30681e3 100644 --- a/app/client/widgets/FormulaEditor.ts +++ b/app/client/widgets/FormulaEditor.ts @@ -183,14 +183,13 @@ export class FormulaEditor extends NewBaseEditor { // By not doing anything special here we assume that the input element will take the focus. return; } - - // Allow clicking the error message. - if (ev.target instanceof HTMLElement && ( - ev.target.classList.contains('error_msg') || + } + // Allow clicking the error message. + if (ev.target instanceof HTMLElement && ( + ev.target.classList.contains('error_msg') || ev.target.classList.contains('error_details_inner') - )) { - return; - } + )) { + return; } ev.preventDefault(); this.focus(); @@ -232,19 +231,12 @@ export class FormulaEditor extends NewBaseEditor { ), dom.maybe(options.formulaError, () => [ dom('div.error_msg', testId('formula-error-msg'), - dom.on('click', () => { - if (this.isDetached.get()) { return; } - if (errorDetails.get()){ - hideErrDetails.set(!hideErrDetails.get()); - this._aceEditor.resize(); - } - }), + dom.attr('tabindex', '-1'), dom.maybe(errorDetails, () => dom.domComputed(hideErrDetails, (hide) => cssCollapseIcon( hide ? 'Expand' : 'Collapse', testId('formula-error-expand'), dom.on('click', () => { - if (!this.isDetached.get()) { return; } if (errorDetails.get()){ hideErrDetails.set(!hideErrDetails.get()); this._aceEditor.resize(); @@ -256,6 +248,7 @@ export class FormulaEditor extends NewBaseEditor { ), dom.maybe(use => Boolean(use(errorDetails) && !use(hideErrDetails)), () => dom('div.error_details', + dom.attr('tabindex', '-1'), dom('div.error_details_inner', dom.text(errorDetails), ), @@ -750,10 +743,6 @@ const cssFormulaEditor = styled('div.default_editor.formula_editor_wrapper', ` flex-shrink: 0; } - &-detached .error_msg { - cursor: default; - } - &-detached .code_editor_container { height: 100%; width: 100%; diff --git a/app/client/widgets/TextEditor.css b/app/client/widgets/TextEditor.css index daa5b136..47bf1bcc 100644 --- a/app/client/widgets/TextEditor.css +++ b/app/client/widgets/TextEditor.css @@ -113,7 +113,6 @@ background-color: #ffb6c1; padding: 4px; color: black; - cursor: pointer; white-space: pre-wrap; flex: none; overflow: auto;