diff --git a/CHANGELOG.md b/CHANGELOG.md index d0e68618dd9..ca16e014e29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an error on startup when using portable preferences. [#14729](https://github.com/JabRef/jabref/issues/14729) - We fixed an issue when warning for duplicate entries in the "New Entry" dialog. [#14662](https://github.com/JabRef/jabref/pull/14662) - We fixed the Quality > Automatically set file links button. Now if a file is moved, the button can relink the moved file to the broken linked file. [#9798](https://github.com/JabRef/jabref/issues/9798) +- We fixed an issue where bulk import operations polluted the navigation history, making the Back/Forward buttons navigate through imported entries instead of only user-selected entries. [#13878](https://github.com/JabRef/jabref/issues/13878) - We fixed an issue where JabRef would not start on Linux ARM due to missing binaries for postgres-embedded [#14783](https://github.com/JabRef/jabref/issues/14783) - We fixed an issue where JaRef would not correctly remember the opened side panels in the preferences [#14818](https://github.com/JabRef/jabref/issues/14818) diff --git a/jabgui/src/main/java/org/jabref/gui/LibraryTab.java b/jabgui/src/main/java/org/jabref/gui/LibraryTab.java index c186bedcbf6..8cff7a80296 100644 --- a/jabgui/src/main/java/org/jabref/gui/LibraryTab.java +++ b/jabgui/src/main/java/org/jabref/gui/LibraryTab.java @@ -822,6 +822,25 @@ public void insertEntry(final BibEntry bibEntry) { insertEntries(List.of(bibEntry)); } + /** + * Inserts the given entries into the database and updates the UI accordingly. + *

+ * For single-entry imports, the entry is selected and optionally opened in the editor + * (based on user preferences), which adds it to the navigation history. + *

+ *

+ * For bulk imports (multiple entries), all entries remain selected but individual + * entry focus is skipped. This prevents pollution of the navigation history with + * entries the user never explicitly clicked on. + *

+ *

+ * This behavior addresses issue #13878 where bulk imports were creating "ghost" + * navigation history entries. + *

+ * + * @param entries the list of entries to insert; must not be empty + * @see Issue #13878 + */ public void insertEntries(final List entries) { if (entries.isEmpty()) { return; @@ -831,10 +850,17 @@ public void insertEntries(final List entries) { getUndoManager().addEdit(new UndoableInsertEntries(bibDatabaseContext.getDatabase(), entries)); markBaseChanged(); stateManager.setSelectedEntries(entries); - if (preferences.getEntryEditorPreferences().shouldOpenOnNewEntry()) { - showAndEdit(entries.getFirst()); - } else { - clearAndSelect(entries.getFirst()); + + // Only show/select individual entry for single-entry imports. + // For bulk imports (size > 1), we skip the clearAndSelect call. + // This prevents navigation history pollution because the listener + // only adds to history when entries.size() == 1. + if (entries.size() == 1) { + if (preferences.getEntryEditorPreferences().shouldOpenOnNewEntry()) { + showAndEdit(entries.getFirst()); + } else { + clearAndSelect(entries.getFirst()); + } } }