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

Preventing library disappearing when closing tab #12909

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Zurtar
Copy link
Contributor

@Zurtar Zurtar commented Apr 7, 2025

Closes #12894

Fixes a bug that caused a library to be hidden if you have two libraries and the Welcome tab open, then close the tab directly to the right of the Welcome tab.

Added a check to see if the Welcome tab was selected automatically after a library is closed, and if so, the next tab is selected instead.

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • [/] Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • [/] Screenshots added in PR description (if change is visible to the user)
  • 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.

Zurtar added 9 commits April 7, 2025 15:17
If you have two databases and the welcome tab open, then close the tab directly to the right of the welcome tab.

The top bar will be hidden resulting in you "losing" the other database.
Now if a user closes a tab beside the Home Page tab and there are other libraries active it will go to the other library instead of the Home page
This reverts commit 144b782.
@Zurtar Zurtar marked this pull request as ready for review April 9, 2025 22:42
@@ -344,6 +344,21 @@ private void initBindings() {
stateManager.setActiveDatabase(libraryTab.getBibDatabaseContext());
stateManager.activeTabProperty().set(Optional.of(libraryTab));
} else if (selectedTab == null || selectedTab instanceof WelcomeTab) {
if (stateManager.getActiveDatabase().isPresent()) {
Copy link

Choose a reason for hiding this comment

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

The code should follow the fail fast principle by immediately handling invalid states and returning early instead of nesting logic inside else branches. The current implementation nests logic inside an if statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Library disappeared and Welcome tab is shown instead
1 participant