From 37593bfe04c47547bcb3883185be671b5a2d7834 Mon Sep 17 00:00:00 2001 From: Amir Mullagaliev <138519917+mulla028@users.noreply.github.com> Date: Fri, 29 Nov 2024 12:08:25 -0500 Subject: [PATCH] Click on entry at "Check integrity" focus bug fixed (#12022) * Two lines added: comment and the getScene().getWindow().requestFocus(); to make sure that focus goes to the field even when dialog window is opened * Focus bug added to the Changelog's Fix field * setFocusToField() fixed focus for JournalTitle Field * Checkstyle Applied * Added line in setFocusToField() to force opening every tab before selecting one --- CHANGELOG.md | 1 + .../jabref/gui/entryeditor/EntryEditor.java | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 342df6c1314..0cc4fbe4094 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -123,6 +123,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where trying to open a library from a failed mounted directory on Mac would cause an error. [#10548](https://github.com/JabRef/jabref/issues/10548) - We fixed an issue when the preview was out of sync. [#9172](https://github.com/JabRef/jabref/issues/9172) - We fixed an issue where identifier paste couldn't work with Unicode REPLACEMENT CHARACTER. [#11986](https://github.com/JabRef/jabref/issues/11986) +- We fixed an issue when click on entry at "Check Integrity" wasn't properly focusing the entry and field. [#11997](https://github.com/JabRef/jabref/issues/11997) ### Removed diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 3a2bd6f2258..ab1bb640dfe 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -13,6 +13,7 @@ import java.util.SortedSet; import java.util.stream.Collectors; +import javafx.application.Platform; import javafx.fxml.FXML; import javafx.geometry.Side; import javafx.scene.control.Button; @@ -61,6 +62,7 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibEntryTypesManager; +import org.jabref.model.entry.EntryConverter; import org.jabref.model.entry.field.Field; import org.jabref.model.util.DirectoryMonitorManager; import org.jabref.model.util.FileUpdateMonitor; @@ -463,11 +465,26 @@ private void fetchAndMerge(EntryBasedFetcher fetcher) { public void setFocusToField(Field field) { UiTaskExecutor.runInJavaFXThread(() -> { + Field actualField = field; + boolean fieldFound = false; for (Tab tab : tabbed.getTabs()) { + tabbed.getSelectionModel().select(tab); if ((tab instanceof FieldsEditorTab fieldsEditorTab) - && fieldsEditorTab.getShownFields().contains(field)) { + && fieldsEditorTab.getShownFields().contains(actualField)) { tabbed.getSelectionModel().select(tab); - fieldsEditorTab.requestFocus(field); + Platform.runLater(() -> { + fieldsEditorTab.requestFocus(actualField); + }); + // This line explicitly brings focus back to the main window containing the Entry Editor. + getScene().getWindow().requestFocus(); + fieldFound = true; + break; + } + } + if (!fieldFound) { + Field aliasField = EntryConverter.FIELD_ALIASES.get(field); + if (aliasField != null) { + setFocusToField(aliasField); } } });