Fix drag & drop interfered with mouse selection when editing tag

This commit is contained in:
nathan 2023-12-19 13:44:29 -07:00 committed by ralf
parent 0dfeae9b16
commit 469c0cf742
2 changed files with 8 additions and 3 deletions

View File

@ -297,7 +297,6 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
pull: pull, pull: pull,
put: !(this.readonly || this.disabled) put: !(this.readonly || this.disabled)
}, },
// filter: "[isEditing],.et2-no-drag",
onEnd: this.handleSortEnd onEnd: this.handleSortEnd
}); });
} }
@ -935,6 +934,7 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
{ {
const readonly = (this.readonly); const readonly = (this.readonly);
const isEditable = !readonly; const isEditable = !readonly;
const isValid = this.validateAddress(value);
return html` return html`
<et2-email-tag <et2-email-tag
@ -943,6 +943,7 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
class=${classMap({ class=${classMap({
"et2-select-draggable": !this.readonly && this.allowDragAndDrop, "et2-select-draggable": !this.readonly && this.allowDragAndDrop,
})} })}
variant=${this.isValid ? nothing : "danger"}
.fullEmail=${this.fullEmail} .fullEmail=${this.fullEmail}
.onlyEmail=${this.onlyEmail} .onlyEmail=${this.onlyEmail}
.value=${live(value)} .value=${live(value)}

View File

@ -200,10 +200,14 @@ export class Et2Tag extends Et2Widget(SlTag)
} }
this.getRootNode().host.hide() this.getRootNode().host.hide()
this.isEditing = true; this.isEditing = true;
this.setAttribute("isEditing", ""); this.setAttribute("contenteditable", "true");
this.requestUpdate(); this.requestUpdate();
this.updateComplete.then(() => this.updateComplete.then(() =>
{ {
// This stops drag and drop from interfereing with mouse edits
this._editNode.input.setAttribute("contenteditable", "true");
this._editNode.focus(); this._editNode.focus();
}) })
} }
@ -211,7 +215,7 @@ export class Et2Tag extends Et2Widget(SlTag)
stopEdit() stopEdit()
{ {
this.isEditing = false; this.isEditing = false;
this.removeAttribute("isEditing"); this.removeAttribute("contenteditable");
let event = new Event("change", { let event = new Event("change", {
bubbles: true bubbles: true
}); });