mirror of
https://github.com/zotero/zotero.git
synced 2026-09-21 00:22:44 +00:00
Fix broken creator autocomplete if place becomes a base field
Well this was a wild one to debug.
Creator fields were only initialized for autocomplete due to a series of
>10-year-old bugs:
1) In `showEditor()`, `Zotero.ItemFields.isAutocompleteField(fieldName)`
was called for creator fields, which would pass, e.g.,
`creator-0-lastName`.
2) In `isAutocompleteField()`, `ItemFields.getName()` would normalize
`creator-0-lastName` to `false`, since it's not a valid field.
3) `isAutocompleteField()` listed `place` as a base field despite its
not having any mapped fields, so when `getTypeFieldsFromBase()` was
called on it, the return value would be `false`, which would be added
to the list of autocomplete fields, which would mean that the
normalized field of `false` from `creator-0-lastName` would match,
which would mean that `isAutocompleteField('creator-0-lastName')`
would always return true...as long as `place` never gained a mapped
field.
Except `isAutocompleteField()` wasn't supposed to be the test for
initializing autocomplete for creator fields anyway -- `fieldName ==
'creator'` was. But `fieldName` is something like `creator-0-lastName`,
not `creator`, which meant that that test always failed, which meant
that if `place` did gain a mapped field, both tests would fail, which
would cause the creator field not to be initialized for autocomplete,
which would cause it to break as soon as you started to type into it.
This fixes that.
This commit is contained in:
parent
a78860f092
commit
3be8abeae2
2 changed files with 7 additions and 4 deletions
|
|
@ -1573,8 +1573,7 @@
|
|||
t.setAttribute('rows', 8);
|
||||
}
|
||||
// Add auto-complete for certain fields
|
||||
else if (Zotero.ItemFields.isAutocompleteField(fieldName)
|
||||
|| fieldName == 'creator') {
|
||||
else if (field == 'creator' || Zotero.ItemFields.isAutocompleteField(fieldName)) {
|
||||
t = document.createElement("input", { is: 'shadow-autocomplete-input' });
|
||||
t.setAttribute('autocompletesearch', 'zotero');
|
||||
|
||||
|
|
|
|||
|
|
@ -349,7 +349,11 @@ Zotero.ItemFields = new function() {
|
|||
|
||||
|
||||
this.isAutocompleteField = function (field) {
|
||||
field = this.getName(field);
|
||||
var fieldName = this.getName(field);
|
||||
if (!fieldName) {
|
||||
Zotero.logError(`Can't check autocomplete for invalid field '${field}'`);
|
||||
return false;
|
||||
}
|
||||
|
||||
var autoCompleteFields = [
|
||||
'journalAbbreviation',
|
||||
|
|
@ -379,7 +383,7 @@ Zotero.ItemFields = new function() {
|
|||
autoCompleteFields = autoCompleteFields.concat(add);
|
||||
}
|
||||
|
||||
return autoCompleteFields.indexOf(field) != -1;
|
||||
return autoCompleteFields.includes(fieldName);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue