From 2ebf350bdf0b50214da53a5abbb16f81627984cd Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Mon, 11 Mar 2024 23:47:22 -0400 Subject: [PATCH] (core) Disable drag-and-drop in active form input Summary: Drag-and-drop was interfering with text selection in inputs for form labels and paragraphs. Test Plan: Manual. Reviewers: jarek Reviewed By: jarek Subscribers: jarek Differential Revision: https://phab.getgrist.com/D4209 --- app/client/components/Forms/Editor.ts | 5 +++++ app/client/components/Forms/Paragraph.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/app/client/components/Forms/Editor.ts b/app/client/components/Forms/Editor.ts index 26e6220e..46bb6814 100644 --- a/app/client/components/Forms/Editor.ts +++ b/app/client/components/Forms/Editor.ts @@ -123,6 +123,11 @@ export function buildEditor(props: Props, ...args: IDomArgs) { dom.on('dragstart', (ev) => { // Prevent propagation, as we might be in a nested editor. ev.stopPropagation(); + if (props.editMode?.get()) { + ev.preventDefault(); + return; + } + ev.dataTransfer?.setData('text/plain', JSON.stringify(box.toJSON())); ev.dataTransfer!.dropEffect = "move"; dragging.set(true); diff --git a/app/client/components/Forms/Paragraph.ts b/app/client/components/Forms/Paragraph.ts index 650b97ac..44fa8c1c 100644 --- a/app/client/components/Forms/Paragraph.ts +++ b/app/client/components/Forms/Paragraph.ts @@ -27,6 +27,7 @@ export class ParagraphModel extends BoxModel { return buildEditor({ box: this, overlay: this._overlay, + editMode, content: css.cssMarkdownRendered( css.markdown(use => use(text) || '', dom.hide(editMode)), dom.maybe(use => !use(text) && !use(editMode), () => cssEmpty('(empty)')),