Fix additional breakage when bidi.browser.ui is true
Some checks are pending
CI / Build, Upload, Test (push) Waiting to run

Broken by me in an edit to 181afb9 (#4534)

Follow-up to previous commit
This commit is contained in:
Dan Stillman 2024-08-14 03:41:10 -04:00
parent ec50539e80
commit 531e8697be
2 changed files with 28 additions and 6 deletions

View file

@ -424,8 +424,24 @@ Zotero.ItemFields = new function() {
* @returns {'auto' | 'ltr' | 'rtl'}
*/
this.getDirection = function (itemTypeID, field, itemLanguage) {
field = this.getName(this.getBaseIDFromTypeAndField(itemTypeID, field) || field);
// Primary fields: follow app locale
switch (field) {
case 'dateAdded':
case 'dateModified':
case 'accessDate':
return Zotero.dir;
}
var fieldName = this.getName(fieldName);
if (!fieldName) {
return 'auto';
}
var baseField = this.getBaseIDFromTypeAndField(itemTypeID, fieldName);
if (baseField) {
fieldName = this.getName(baseField);
}
switch (fieldName) {
// Certain fields containing IDs, numbers, and data: always LTR
case 'ISBN':
case 'ISSN':
@ -449,11 +465,7 @@ Zotero.ItemFields = new function() {
case 'language':
case 'extra':
return 'ltr';
// Primary fields: follow app locale
case 'dateAdded':
case 'dateModified':
case 'accessDate':
return Zotero.dir;
// Everything else: guess based on the language if we have one; otherwise auto
default:
if (itemLanguage) {

View file

@ -44,4 +44,14 @@ describe("Zotero.ItemFields", function () {
);
});
});
describe("#getDirection()", function () {
it("should return 'auto' for non-field", function () {
assert.equal(Zotero.ItemFields.getDirection('book', 'creator-0-lastName', ''), 'auto');
});
it("should follow app locale for primary field", function () {
assert.equal(Zotero.ItemFields.getDirection('book', 'dateAdded', ''), Zotero.dir)
});
});
})