(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
This commit is contained in:
George Gevoian 2024-03-11 23:47:22 -04:00
parent e4d104ee41
commit 2ebf350bdf
2 changed files with 6 additions and 0 deletions

View File

@ -123,6 +123,11 @@ export function buildEditor(props: Props, ...args: IDomArgs<HTMLElement>) {
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);

View File

@ -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)')),