Check against base fields

This commit is contained in:
Dan Stillman 2024-08-10 01:24:53 -04:00
parent 62c59a36ab
commit 818e186bec
3 changed files with 9 additions and 13 deletions

View file

@ -1506,7 +1506,9 @@
if (lazy.BIDI_BROWSER_UI) {
// Attempt to guess text direction automatically
let language = this.item.getField('language');
valueElement.dir = Zotero.ItemFields.getDirection(fieldName, language);
valueElement.dir = Zotero.ItemFields.getDirection(
this.item.itemTypeID, fieldName, language
);
}
// Regardless, align the text in unfocused fields consistently, following the locale's direction

View file

@ -2861,7 +2861,9 @@ var ItemTree = class ItemTree extends LibraryTree {
let textSpanAriaLabel = [textWithFullStop, itemTypeAriaLabel, tagAriaLabel, retractedAriaLabel].join(' ');
textSpan.className = "cell-text";
if (lazy.BIDI_BROWSER_UI) {
textSpan.dir = Zotero.ItemFields.getDirection(column.dataKey, item.getField('language'));
textSpan.dir = Zotero.ItemFields.getDirection(
item.itemTypeID, column.dataKey, item.getField('language')
);
}
textSpan.setAttribute('aria-label', textSpanAriaLabel);

View file

@ -421,12 +421,13 @@ Zotero.ItemFields = new function() {
/**
* Guess the text direction of a field, using the item's language field if available.
*
* @param {number} itemTypeID
* @param {string | number} field
* @param {string} [itemLanguage]
* @returns {'auto' | 'ltr' | 'rtl'}
*/
this.getDirection = function (field, itemLanguage) {
field = this.getName(field) || field;
this.getDirection = function (itemTypeID, field, itemLanguage) {
field = this.getName(this.getBaseIDFromTypeAndField(itemTypeID, field) || field);
switch (field) {
// Certain fields containing IDs, numbers, and data: always LTR
case 'ISBN':
@ -438,24 +439,15 @@ Zotero.ItemFields = new function() {
case 'numberOfVolumes':
case 'issue':
case 'runningTime':
case 'billNumber':
case 'number':
case 'versionNumber':
case 'documentNumber':
case 'patentNumber':
case 'applicationNumber':
case 'priorityNumbers':
case 'episodeNumber':
case 'reportNumber':
case 'codeNumber':
case 'publicLawNumber':
case 'archiveID':
case 'codePages':
case 'pages':
case 'numPages':
case 'seriesNumber':
case 'edition':
case 'identifier':
case 'citationKey':
case 'language':
case 'extra':