Tags box: Fix multiline editing after editable-text changes

This commit is contained in:
Abe Jellinek 2024-01-03 10:49:33 -08:00 committed by Dan Stillman
parent fca87eff9c
commit 691e5d8cc1
2 changed files with 17 additions and 1 deletions

View file

@ -44,6 +44,10 @@
return this.hasAttribute('nowrap');
}
set noWrap(noWrap) {
this.toggleAttribute('nowrap', noWrap);
}
get multiline() {
return this.hasAttribute('multiline');
}
@ -134,7 +138,7 @@
}
sizeToContent = () => {
// Add a temp span, fetch it's width with current paddings and set max-width based on that
// Add a temp span, fetch its width with current paddings and set max-width based on that
let span = document.createElement("span");
span.innerText = this.value;
this.append(span);

View file

@ -440,12 +440,18 @@
};
makeMultiline(editable, value) {
editable.noWrap = false;
editable.multiline = true;
editable.value = value;
// Move cursor to end
editable.ref.selectionStart = value.length;
}
makeSingleLine(editable) {
editable.noWrap = true;
editable.multiline = false;
}
saveTag = async (event) => {
var textbox = event.currentTarget;
@ -467,6 +473,7 @@
// If row hasn't changed, we're done
if (oldValue == value) {
this.makeSingleLine(textbox);
return;
}
@ -546,6 +553,11 @@
throw e;
}
}
// If we didn't remove the textbox, make it single-line
if (textbox.parentElement) {
this.makeSingleLine(textbox);
}
};
newTag() {