From e5ebc4668ce8933baa7293419757421e12a8935a Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Thu, 16 Sep 2021 09:56:07 -0700 Subject: [PATCH] (core) Disable mousedown on token delete button Summary: This change prevents dragging tokens when the cursor is over the delete button. Now, trying to drag after mousedown over the delete button will do nothing if the cursor is released outside the delete button, and will delete if the cursor is released inside the delete button. Test Plan: Tested manually. Reviewers: alexmojaki Reviewed By: alexmojaki Differential Revision: https://phab.getgrist.com/D3024 --- app/client/lib/TokenField.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/client/lib/TokenField.ts b/app/client/lib/TokenField.ts index f2cfb61e..7f465052 100644 --- a/app/client/lib/TokenField.ts +++ b/app/client/lib/TokenField.ts @@ -126,7 +126,12 @@ export class TokenField extends Disposable { cssToken(this._options.renderToken(t.token), dom.cls('selected', (use) => use(this._selection).has(t)), _options.readonly ? null : [ - cssDeleteButton(cssDeleteIcon('CrossSmall'), testId('tokenfield-delete')), + cssDeleteButton( + // Ignore mousedown events, so that tokens aren't draggable by the delete button. + dom.on('mousedown', (ev) => ev.stopPropagation()), + cssDeleteIcon('CrossSmall'), + testId('tokenfield-delete') + ), dom.on('click', (ev) => this._onTokenClick(ev, t)), dom.on('mousedown', (ev) => this._onMouseDown(ev, t)) ],