Item box: Fix Short Title rendering as multiline

Also, rerender editable-text when noWrap changes.
This commit is contained in:
Abe Jellinek 2024-01-26 13:38:29 -05:00
parent 1cc5c1ce2e
commit 00ca99ae86
2 changed files with 8 additions and 4 deletions

View file

@ -169,7 +169,9 @@
render() { render() {
let autocompleteParams = this.autocomplete; let autocompleteParams = this.autocomplete;
let autocompleteEnabled = !this.multiline && !!autocompleteParams; let autocompleteEnabled = !this.multiline && !!autocompleteParams;
if (!this._input || autocompleteEnabled !== (this._input.constructor.name === 'AutocompleteInput')) { if (!this._input
|| (this._input.constructor.name === 'AutocompleteInput') !== autocompleteEnabled
|| this._input.tagName !== (this.noWrap ? 'input' : 'textarea')) {
let input; let input;
if (autocompleteEnabled) { if (autocompleteEnabled) {
input = document.createElement('input', { is: 'autocomplete-input' }); input = document.createElement('input', { is: 'autocomplete-input' });

View file

@ -1467,13 +1467,15 @@
var fieldID = Zotero.ItemFields.getID(fieldName); var fieldID = Zotero.ItemFields.getID(fieldName);
} }
var isMultiline = Zotero.ItemFields.isMultiline(fieldName) || Zotero.ItemFields.isLong(fieldName); let isMultiline = Zotero.ItemFields.isMultiline(fieldName);
let isLong = Zotero.ItemFields.isLong(fieldName);
var valueElement = document.createXULElement("editable-text"); var valueElement = document.createXULElement("editable-text");
valueElement.className = 'value'; valueElement.className = 'value';
if (isMultiline) { if (isMultiline) {
valueElement.setAttribute('multiline', true); valueElement.setAttribute('multiline', true);
} }
else { else if (!isLong) {
// Usual fields occupy all available space and keep info on one line // Usual fields occupy all available space and keep info on one line
valueElement.setAttribute("nowrap", true); valueElement.setAttribute("nowrap", true);
} }
@ -1548,7 +1550,7 @@
else { else {
valueElement.style.textAlign = 'left'; valueElement.style.textAlign = 'left';
} }
if (!fieldName.includes("creator")) { if (!isLong && !fieldName.includes("creator")) {
// autocomplete for creator names is added in addCreatorRow // autocomplete for creator names is added in addCreatorRow
this.addAutocompleteToElement(valueElement); this.addAutocompleteToElement(valueElement);
} }