diff --git a/CHANGELOG.md b/CHANGELOG.md index a1b7599d741..a388f06b88e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -122,6 +122,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - Enhanced field selection logic in the Merge Entries dialog when fetching from DOI to prefer valid years and entry types. [#12549](https://github.com/JabRef/jabref/issues/12549) - We fixed an issue where theme or font size are not respected for all dialogs [#13558](https://github.com/JabRef/jabref/issues/13558) - We removed unnecessary spacing and margin in the AutomaticFieldEditor. [#13792](https://github.com/JabRef/jabref/pull/13792) +- We fixed an issue where global search auto-completion only worked after switching tabs. [#11428](https://github.com/JabRef/jabref/issues/11428) ### Removed diff --git a/jabgui/src/main/java/org/jabref/gui/LibraryTab.java b/jabgui/src/main/java/org/jabref/gui/LibraryTab.java index e68abe6fa04..a05eacf3020 100644 --- a/jabgui/src/main/java/org/jabref/gui/LibraryTab.java +++ b/jabgui/src/main/java/org/jabref/gui/LibraryTab.java @@ -161,6 +161,8 @@ public class LibraryTab extends Tab implements CommandSelectionTab { private final AiService aiService; + private Runnable autoCompleterChangedListener; + /** * @param isDummyContext Indicates whether the database context is a dummy. A dummy context is used to display a progress indicator while parsing the database. * If the context is a dummy, the Lucene index should not be created, as both the dummy context and the actual context share the same index path {@link BibDatabaseContext#getFulltextIndexPath()}. @@ -258,6 +260,10 @@ private void initializeComponentsAndListeners(boolean isDummyContext) { }); } + public void setAutoCompleterChangedListener(@NonNull Runnable listener) { + this.autoCompleterChangedListener = listener; + } + private static void addChangedInformation(StringBuilder text) { text.append("\n"); text.append(Localization.lang("The library has been modified.")); @@ -303,7 +309,10 @@ private void onDatabaseLoadingSucceed(ParserResult result) { } setDatabaseContext(result.getDatabaseContext()); - + // Notify listeners that the auto-completer may have changed + if (autoCompleterChangedListener != null) { + autoCompleterChangedListener.run(); + } LOGGER.trace("loading.set(false);"); loading.set(false); dataLoadingTask = null; diff --git a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java index c5e0fdba932..aeb7217775d 100644 --- a/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -403,6 +403,9 @@ private void initBindings() { stateManager.searchResultSize(SearchType.NORMAL_SEARCH).bind(libraryTab.resultSizeProperty()); globalSearchBar.setAutoCompleter(libraryTab.getAutoCompleter()); + // Listen for auto-completer changes after real context is loaded + libraryTab.setAutoCompleterChangedListener(() -> globalSearchBar.setAutoCompleter(libraryTab.getAutoCompleter())); + // [impl->req~maintable.focus~1] Platform.runLater(() -> libraryTab.getMainTable().requestFocus());