Skip to content

Commit 75d90f3

Browse files
committed
feat: enable autodetect of Wikidata/ISNI on Edition/Work identifier inputs
1 parent 6d2c117 commit 75d90f3

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

openlibrary/components/IdentifiersInput.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,19 +302,21 @@ export default {
302302
}
303303
document.querySelector(this.output_selector).innerHTML = html;
304304
},
305+
/**
306+
* Auto-selects identifier type dropdown based on input pattern (e.g., Q12345 → Wikidata).
307+
* Only selects types available in the current page's identifier config.
308+
* Enables autodetect for editions/works (previously author-only).
309+
*/
305310
selectIdentifierByInputValue: function() {
306-
// Ignore for edition identifiers
307-
if (this.saveIdentifiersAsList) {
308-
return;
309-
}
310-
// Selects the dropdown identifier based on the input value when possible
311311
for (const idtype in identifierPatterns) {
312312
if (this.inputValue.match(identifierPatterns[idtype])){
313-
this.selectedIdentifier = idtype;
314-
break;
313+
/** Only select identifier types available in page config (prevents selecting unsupported types) */
314+
if (this.identifierConfigsByKey && this.identifierConfigsByKey[idtype]) {
315+
this.selectedIdentifier = idtype;
316+
break;
317+
}
315318
}
316319
}
317-
318320
}
319321
}
320322
}

0 commit comments

Comments
 (0)