Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click on entry at "Check integrity" focus bug fixed #12022

Merged
merged 6 commits into from
Nov 29, 2024

Conversation

mulla028
Copy link
Contributor

@mulla028 mulla028 commented Oct 19, 2024

Description

This PR aims on a bug fix, when user was clicking on entry at Check Integrity, entry was focused, but not a field in entry editor.

Changes

In src/main/java/org/jabref/gui/entryeditor/EntryEditor.java two lines of code were added to setFocusToField()

  1. inside for-loop forcing to open every tab to render all fields, before selection is made tabbed.getSelectionModel().select(tab);
  2. getScene().getWindow().requestFocus();
  3. Added condition that checks if Field wasn't selected , so it continues to check if ALIAS of that field exists, if ALIAS exists, if so, it replaces Field to it's ALIAS, otherwise nothing happens.
if (!fieldFound) {
    Field aliasField = EntryConverter.FIELD_ALIASES.get(field);
       if (aliasField != null) {
           setFocusToField(aliasField);
        }
 }

This line explicitly brings focus back to the main window containing the Entry Editor. It fixes a field focus bug.

Video of changed UI

Screen.Recording.2024-11-29.at.10.19.05.AM.mov

As you can see on screenshot bug is fixed!

Mandatory checks

  • I own the copyright of the code submitted and I licence it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

…); to make sure that focus goes to the field even when dialog window is opened
@mulla028
Copy link
Contributor Author

@koppor
I really enjoyed contributing on your project! Thank you for this opportunity!
If you have any questions or suggestions regarding this PR, just let me know 🫡

@koppor koppor marked this pull request as draft October 19, 2024 09:22
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please re-iterate on the issue description: #11997

Here, especially for you, another description.

  1. Start JabRef

  2. Open chocolate.bib - you find it at https://github.com/JabRef/jabref/blob/main/src/test/resources/testbib/Chocolate.bib

  3. Seelct entry "Cocoa and Cardiovascular Health"

  4. Select tab "General" in Entry editor

  5. Select field DOI
    image

  6. Go to Menu "Quality"

  7. Click on "Check integrity"

  8. Double click on the first entry "Corti_2009"
    image

  9. See that nothing happens

In Step 9, the tab "Requried fiels" and the field "Citatoinkey" should be focused.

@koppor koppor added the status: changes required Pull requests that are not yet complete label Oct 19, 2024
@mulla028
Copy link
Contributor Author

Please re-iterate on the issue description: #11997

Here, especially for you, another description.

  1. Start JabRef
  2. Open chocolate.bib - you find it at https://github.com/JabRef/jabref/blob/main/src/test/resources/testbib/Chocolate.bib
  3. Seelct entry "Cocoa and Cardiovascular Health"
  4. Select tab "General" in Entry editor
  5. Select field DOI
    image
  6. Go to Menu "Quality"
  7. Click on "Check integrity"
  8. Double click on the first entry "Corti_2009"
    image
  9. See that nothing happens

In Step 9, the tab "Requried fiels" and the field "Citatoinkey" should be focused.

Thank you for your feedback! Will do my best!

@mulla028
Copy link
Contributor Author

@koppor
You mean that after I opened General tab, and then in Check Integrity once I double click on entry it should focus on both fields:

  1. Citation Key
  2. Field?

@Siedlerchr
Copy link
Member

It should focus on the field that is reported in the integrity check

@mulla028
Copy link
Contributor Author

It should focus on the field that is reported in the integrity check

Thank you for your response! I'm pretty new to this project. Would it be possible to share a little detailed description? If not, I will do my best to figure all out myself.

@mulla028
Copy link
Contributor Author

mulla028 commented Oct 23, 2024

@Siedlerchr
What I don't understand is that current PR supports this feature according on as much I understand.
Following an example by @koppor, he claims that If I click on the first entry Corti2009 nothing happens. However, my end shows me that current field CitationKey focused.
Sharing with you screenshot:
image

Please let me know if I misunderstand you! Thank you!

@Siedlerchr
Copy link
Member

That is indeed correct, however, in my tests jumping to another tab only works sometimes:

  1. Open chocolate bib
  2. check integrity
  3. click on an entry with DOI => The required information tab stays open

However, if I now select the general Tab of an entry, I am able to jump to it/again to it
Same applies to pages field

Please check why the tab needs to have been selected first

@mulla028
Copy link
Contributor Author

That is indeed correct, however, in my tests jumping to another tab only works sometimes:

  1. Open chocolate bib
  2. check integrity
  3. click on an entry with DOI => The required information tab stays open

However, if I now select the general Tab of an entry, I am able to jump to it/again to it Same applies to pages field

Please check why the tab needs to have been selected first

Oh now I understand where you are getting at! Thank you!

@mulla028
Copy link
Contributor Author

mulla028 commented Nov 26, 2024

@Siedlerchr, @koppor Hello!

Is this issue still relevant? If so, I would love to continue working on it 😄
I had to figure out some staff at college, and wasn't able to finish.
Previous time, when I'd been trying to fix this bug, I couldn't understand if I'd been digging in the right direction. I really want to fix this bug, I took it personal 😆

File that I suspect contains a bug: src/main/java/org/jabref/gui/entryeditor/EntryEditor.java

@Siedlerchr
Copy link
Member

Sure, that's great to here! You can continue with your PR for this issue

@mulla028
Copy link
Contributor Author

mulla028 commented Nov 27, 2024

@Siedlerchr Hello again!
Could you do me a favour, I'm working on this project as part of my Open-source college course. I have already showed that I worked on this issue. Would it be possible to create a new issue related to this bug, assign me, and expand it a little bit, so it could count towards my college work. I would really appreciate it🙏
I'm asking for the reason, that this bug was already expanded a little bit.

@koppor
Copy link
Member

koppor commented Nov 28, 2024

@mulla028 We need to be fair to all contributors. We try to treat them equally. First, resolve issue #11997 completely. At least one case of it does not work. Thus, maybe the code is buggy and should be changed. If there are follow-up issues, we can create other issues. - But for a single line of code added and not fixing everything, there should be more time spend for a solution. I fully understand that UI programming is hard, because it is very much trial and error. - The hint is to spend time to a minimal working example: Creating a new application from scratch and trying to replicate the issue there - and fixing it there. Then porting back the fix. https://github.com/Siedlerchr/javafxreproducer can be a start.

@mulla028
Copy link
Contributor Author

@mulla028 We need to be fair to all contributors. We try to treat them equally. First, resolve issue #11997 completely. At least one case of it does not work. Thus, maybe the code is buggy and should be changed. If there are follow-up issues, we can create other issues. - But for a single line of code added and not fixing everything, there should be more time spend for a solution. I fully understand that UI programming is hard, because it is very much trial and error. - The hint is to spend time to a minimal working example: Creating a new application from scratch and trying to replicate the issue there - and fixing it there. Then porting back the fix. https://github.com/Siedlerchr/javafxreproducer can be a start.

Alright, I just tried. If you never try - you never know 😆

@mulla028
Copy link
Contributor Author

mulla028 commented Nov 28, 2024

@Siedlerchr @koppor I noticed that #11997 fixed in one of the PRs.

Once updated my branch I witnessed that everything works as you expected:

ScreenRecording2024-11-28at1 45 43PM-ezgif com-video-to-gif-converter

@koppor
Copy link
Member

koppor commented Nov 28, 2024

Does not work for aliassed fields:

image

@mulla028
Copy link
Contributor Author

Does not work for aliassed fields:

image

Thank you for your response, will take a look at it, and try to fix it.

@koppor
Copy link
Member

koppor commented Nov 28, 2024

That is indeed correct, however, in my tests jumping to another tab only works sometimes:

@Siedlerchr Can you refine?

1. Open chocolate bib
2. check integrity
3. click on an entry with DOI => The required information tab stays open

I go to Corti_2009 and select "Other fields" and select "Publisher"

image

Then, I do "Check integrity"

Then, I click Corti_2009. Works.

image

Is this a macOS / Windows thing? Timing maybe?

@koppor
Copy link
Member

koppor commented Nov 28, 2024

Note that double click does not work, it is a single click!

@koppor
Copy link
Member

koppor commented Nov 28, 2024

Note that double click does not work, it is a single click!

I updated the issue title. - Please update the PR description and add a CHANGELOG.md entry, too.

@koppor
Copy link
Member

koppor commented Nov 28, 2024

Proposal to proceed:

  1. @mulla028 Adds a CHANGELOG.md entry
  2. @Siedlerchr Checks the issue on macOS again
  3. @mulla028 Works on field aliasses in parallel.

@mulla028
Copy link
Contributor Author

mulla028 commented Nov 28, 2024

Note that double click does not work, it is a single click!

Do I have to disable single click, and set focus on double click only, right?

OS: macOS Sequoia 15.1.1

UPD: According to the new issue title. I guess, I have to leave single click option

@mulla028 mulla028 changed the title Double click on entry at "Check integrity" focus bug fixed Click on entry at "Check integrity" focus bug fixed Nov 28, 2024
@Siedlerchr
Copy link
Member

Siedlerchr commented Nov 28, 2024 via email

@mulla028
Copy link
Contributor Author

mulla028 commented Nov 28, 2024

Might need to verify again but it could be that it got fixed by chance through another commit Amir Mullagaliev @.> schrieb am Do., 28. Nov. 2024, 22:14:

Note that double click does not work, it is a single click! Do I have to disable single click, and set focus on only double click, right? OS: macOS Sequoia 15.1.1 — Reply to this email directly, view it on GitHub <#12022 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACOFZC73WZ4XUWVSDEGFA32C6BRXAVCNFSM6AAAAABQG7LQUWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBWG43DEMBXHA . You are receiving this because you were mentioned.Message ID: @.
>

Probably it got fixed in one of these PRs: #12165 , #12034. But I'm not sure...

@mulla028
Copy link
Contributor Author

mulla028 commented Nov 29, 2024

I found another problem that prevents me from focusing PAGES field, it happens because the tabs in src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java have lazy initialization. Therefore, it means that the fields inside of the tabs aren't initialized until they opened.

e.g., if I try to select entry with PAGES field before I open Optional Fields tab, it won't focus there.
However, once I open that tab and switch to other, and select it again, it will get focused!

Everything that I described is demonstrated in video below!

Screen.Recording.2024-11-28.at.7.50.05.PM.mov

@mulla028
Copy link
Contributor Author

The reason why Journaltitle isn't focusing, that the field name is JOURNALTITLE, but logic searches for the field named JOURNAL, which doesn't exist in Required Fields tab.

It starts inside of src/main/java/org/jabref/gui/integrity/IntegrityCheckDialog.java#onSelectionChanged:

change.getAddedSubList().stream().findFirst().ifPresent(message ->
                    libraryTab.editEntryAndFocusField(message.entry(), message.field()));

message.field() is getting passed as field argument to the editEntryAndFocusField(), so in case of JOURNAL it passes field not as JOURNALTITLE, but as JOURNAL + message: "journal not found in abbreviation list"

@koppor
Copy link
Member

koppor commented Nov 29, 2024

I found another problem that prevents me from focusing PAGES field, it happens because the tabs in src/main/java/org/jabref/gui/entryeditor/FieldsEditorTab.java have lazy initialization. Therefore, it means that the fields inside of the tabs aren't initialized until they opened.

Then try to force opening the tab. Maybe it is as simple as wrapping in Plattform.runlater.

@koppor
Copy link
Member

koppor commented Nov 29, 2024

The reason why Journaltitle isn't focusing, that the field name is JOURNALTITLE, but logic searches for the field named JOURNAL, which doesn't exist in Required Fields tab.

Yeah, first step for the brain teaser.

  • Second step: Check org.jabref.model.entry.EntryConverter#FIELD_ALIASES.
  • Third step: Make use of that map when jumping to a field. Hint: If field is not found, to a get on the Map. If this is non-null, try to find that field. If not found, you can do nothing.

@Siedlerchr
Copy link
Member

There is a method getfieldOrAlias...

public Optional<String> getFieldOrAlias(Field field) {

@koppor
Copy link
Member

koppor commented Nov 29, 2024

There is a method getfieldOrAlias...

public Optional<String> getFieldOrAlias(Field field) {

This is the other way round!

  • There: Give me the content of the field
  • Here: Give me the field belonging to a content

@mulla028
Copy link
Contributor Author

@koppor @Siedlerchr Thank you for your feedback! Will try to make everything work!

@mulla028
Copy link
Contributor Author

Alright, I fixed focus for journaltitle field, take a look at it. Trying to fix pages field

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.

@mulla028
Copy link
Contributor Author

@koppor @Siedlerchr
Issue fixed:

Screen.Recording.2024-11-29.at.10.19.05.AM.mov

@mulla028 mulla028 marked this pull request as ready for review November 29, 2024 15:20
@Siedlerchr
Copy link
Member

Please test with multiple open libraries as well

@@ -468,6 +468,7 @@ public void setFocusToField(Field field) {
Field actualField = field;
boolean fieldFound = false;
for (Tab tab : tabbed.getTabs()) {
tabbed.getSelectionModel().select(tab);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks not right without a condition. What happens with multiple open libraries?
Actually there is a condition below. Why is that not triggered?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works well with multiple opened libraries, just tested.
What condition specifically are you talking about , the very first one inside of for-loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answering the question, why that is not triggered, for the reason, that fieldEditorTab has a lazy initialization, so it doesn't render the fields unless tab opened at least once, that's why I added line 471. I updated description, at the top of this PR, there I described all the changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mulla028
Copy link
Contributor Author

Please test with multiple open libraries as well

Just have tested, works with other libraries that include MONTH, YEAR, LOCATION, and FILE fields

@mulla028
Copy link
Contributor Author

Do you have any other concerns, imo - the only change that I should do is to remove line 468

@mulla028
Copy link
Contributor Author

If you have concerns regarding iteration through the tabbed tabs before the condition, it doesn't include every library. It only iterates through the library that is currently in use.

@Siedlerchr
Copy link
Member

Tested it, works fine, also with custom field

@Siedlerchr Siedlerchr added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed status: changes required Pull requests that are not yet complete labels Nov 29, 2024
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is OK enough.

I left comments for a follow-up. But we merge now to free energy for finishing other PRs.

@@ -463,11 +465,26 @@ private void fetchAndMerge(EntryBasedFetcher fetcher) {

public void setFocusToField(Field field) {
UiTaskExecutor.runInJavaFXThread(() -> {
Field actualField = field;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary as you use recursion in line 484.

Comment on lines +478 to +479
// This line explicitly brings focus back to the main window containing the Entry Editor.
getScene().getWindow().requestFocus();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have wrapped that into Platform.runlater, too (and before the runLater above)

// This line explicitly brings focus back to the main window containing the Entry Editor.
getScene().getWindow().requestFocus();
fieldFound = true;
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a return.

break;
}
}
if (!fieldFound) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If guard can be removed if you use return in 481.

@koppor koppor added this pull request to the merge queue Nov 29, 2024
@mulla028
Copy link
Contributor Author

@koppor @Siedlerchr
I would love to continue working on this project, could you please suggest me issues that I may take?

Merged via the queue into JabRef:main with commit 37593bf Nov 29, 2024
24 checks passed
@Siedlerchr
Copy link
Member

@mulla028 That's great to hear and thanks for coming back and finishing this.
We have enough issues for everyone! I would sugget you check out some of the good first issues https://github.com/orgs/JabRef/projects/5 (fee to take)
or you can look at other issues:
https://github.com/orgs/JabRef/projects/7/views/2

@mulla028
Copy link
Contributor Author

mulla028 commented Nov 29, 2024

Thank you so much!
I really enjoyed working on this project!
I really appreciate your guidelines and patience 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Click on entry at "Check integrity" should focus the entry and field
3 participants