-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Improve search history by attaching change listener #9794
Conversation
Commited modifications regarding the listener attachment.
|
You got partial feedback at #9685 (comment). To judge the question, I need to check the current state. Maybe, you can summarize it? Not sure, when I have time to checkout your PR and check it. Not sure about the others though. |
Briefly, regarding the current state, the bug is fixed and there are no redundant recordings. I’m just wondering if we need the 2nd solution as an additional mechanism to optimize the search history. First solutionAttach a change listener to focus property of search box node, so only when it gets inactive / lost (i.e. user completes search) then we record the query. Also removed the addSearchHistory method call from performSearch and placed it under listener's lambda expression. See pr's description for more details Second solutionEach time a query is recorded, we loop the search history observable list and:
In case both of them return the desired results, we merge the two queries What I implemented?I followed the first solution. |
Totally fine if you don't need the similarity. I'm happy with the solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Code" comments attached.
@koppor I have just uploaded screenshots. |
Thank you for the video! -- I was expecting that there was a dropdown shown. Need to search the PR and check for the decision. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improves the situation, so I would suggest to add a CHANGELOG entry and then we go for a merge. Tests can be done later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my side lgtm so far already
The last time I executed the code locally it worked in intellij. tests were passing. |
Good to hear that it works on your macOS systems (you and @demetres12 use macOS). -- It does not work on my Windows and it also does not work on GitHub. For GitHub, I already showed the links to the failing tests. It is totally unclear to me why this happens. @calixtus Can you run GlobalSearchBarTest.java on your Linux (and maybe Windows) machine? On the one hand, it would be OK for me to disable the tests and to reserve it as "future work" to fix them. On the other hand, working with FXCollections in tests is very fundamental. Thus, we should devote some time to get this working on GitHub (Linux!) and on Windows machines. |
change the Focus method to DefaultTaskExecutor.runAndWaitInJavaFXThread(() -> hBox.requestFocus()); that seemed to do the trick. Wating for the FX thread to execute |
Yeah seems like it worked now 👍 💯 |
Is there a reason the |
Basically, this is a feature of junit5. Back in JUnit 4 they had to be public.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the updates. I have three nitpicks on the testing. I commented - and also updated the code for myself to keep things going. If the tests are green, I will merge.
@koppor the assertFalse check was necessary to ensure the focus listener was working correctly. The assertEquals returned this weird collections type differences until this task executor waiting |
@koppor @Siedlerchr |
* upstream/main: (88 commits) Minimal config for openRewrite Fix missing # Fix modernizer (JabRef#9824) CHANGELOG.md Removed unused code Refined ui Dissolved FileTab and moved contents to EntryTab Renamed CustomEditorFieldsTab to EntryEditorTabsTab Fixed antipattern, fixed radiobutton with checkbox Renamed ImportExportPreferences to ExportPreferences Improve search history by attaching change listener (JabRef#9794) Separated WebSearchPrefs and ExportPrefs Separated WebSearchTab and ExportTab Renamed ImportExportTab to WebSearchTab Fix split multiline localization (JabRef#9814) New Crowdin updates (JabRef#9834) change versin to 0.8.10 remove jacoco version config Bump org.junit.platform:junit-platform-launcher from 1.9.2 to 1.9.3 Bump org.jsoup:jsoup from 1.15.4 to 1.16.1 ...
…biblatex-date-formats * upstream/main: (132 commits) Add four rules not having any effect Apply BooleanChecksNotInverted Remove unused RadioButtonCell Minimal config for openRewrite Fix missing # Fix modernizer (JabRef#9824) CHANGELOG.md Removed unused code Refined ui Dissolved FileTab and moved contents to EntryTab Renamed CustomEditorFieldsTab to EntryEditorTabsTab Fixed antipattern, fixed radiobutton with checkbox Renamed ImportExportPreferences to ExportPreferences Improve search history by attaching change listener (JabRef#9794) Separated WebSearchPrefs and ExportPrefs Separated WebSearchTab and ExportTab Renamed ImportExportTab to WebSearchTab Fix split multiline localization (JabRef#9814) New Crowdin updates (JabRef#9834) change versin to 0.8.10 ...
Fixes #9685
Essentially, we record the search query, only when the user completes the search process and "leaves" the search box. We ensure that, by checking whether the focus is lost or active on search bar and that helps us prevent storing redundant data (e.g prefixes)
What steps are followed?
changes to inactive / lost
About the implementation
Resolving the issue, we attach a change listener to the search box node and call
addSearchHistory
method, only when:- the focus property of search box is lost and
- the search query is not empty.
In case, the two aforementioned conditions are met, we record the query successfully.
Before that, the
addSearchHistory
method was called insideperformSearch
.The
performSearch
was called every time the search box was idle for more than(SEARCH_DELAY = 400)
ms, as a proper waiting time to perform the query and show search results, yet not proper for storing the search queries.Consequently, there were unnecessary data (prefixes) recorded in history, as the user would not type the query that fast (<400ms/character typed). Therefore, we remove the call of
addSearchHistory
and place it under change listener's registration.Change listener is NOT attached : Redundant prefixes are recorded
bug.mov
Change listener is attached : Recording query by the completion of search process
bug-fixed.mov
Note: In both cases I slowtype on purpose, so the search box could be idle for more than 400ms for every character typing.
Compulsory checks