Skip to content

Conversation

@omkarrr2533
Copy link
Contributor

@omkarrr2533 omkarrr2533 commented Dec 12, 2025

Closes #13684

Description

When importing a .bib file into another library using File → Import, groups from the imported file were not appearing in the left sidebar, even though the groups field was correctly set in each entry. This PR implements group merging logic to ensure imported groups are properly displayed alongside existing groups in the target library.

Steps to test

  1. Create first library with group "A":

    • Open JabRef
    • Create a new library (File → New library)
    • Add an entry (e.g., a sample article)
    • Create a group named "A" (right-click in Groups panel → Add group)
    • Assign the entry to group "A"
    • Save as A.bib and close JabRef
  2. Create second library with group "B":

    • Open JabRef again
    • Create a new library
    • Add a different entry
    • Create a group named "B"
    • Assign the entry to group "B"
    • Save as B.bib (keep this library open)
  3. Import and verify:

    • With B.bib still open, go to File → Import
    • Select A.bib and import it
    • Expected result: Both groups "A" and "B" should now be visible in the left sidebar
    • Verify: Entries are correctly assigned to their respective groups
  4. Test edge cases:

    • Import a library with groups into a library that has no groups (should copy all groups)
    • Import a library with a group named "Test" into another library that also has a group named "Test" (should merge, not duplicate)

Mandatory checks

Implementation Details

Files Modified:

  • ImportEntriesViewModel.java: Added mergeGroupsFromImport() method to merge groups from imported library with target library's existing groups, and mergeGroupTrees() helper method for recursive merging
  • CHANGELOG.md: Added entry documenting the fix

Key Features:

  • Groups with identical names are merged recursively, preserving hierarchy
  • New groups are added without duplication
  • If target library has no groups, the entire group tree from import is copied
  • Metadata changes trigger automatic UI refresh to display merged groups immediately

Additional Notes

This fix addresses the core issue where JabRef's import functionality was only importing entries and their metadata fields (including the groups field), but was not extracting and merging the actual group tree structure from the imported library's metadata. The group information existed in the entries but was not reflected in the sidebar's group tree.

Note: As per issue requirements, documentation updates at https://docs.jabref.org/advanced/main-window will be handled in a follow-up after this PR is merged and tested.

- Added group merging logic in ImportEntriesViewModel
- Groups with same name are merged recursively
- Target library with no groups receives complete group tree
- Metadata update triggers UI refresh

Fixes JabRef#13684
@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 12, 2025
@github-actions
Copy link
Contributor

This pull requests was closed without merging. You have been unassigned from the respective issue #13684.

   - Added mergeGroupsFromImport() and mergeGroupTrees() methods to ImportEntriesViewModel
   - Groups from imported libraries now properly merge with existing groups
   - Fixed CHANGELOG.md formatting

   Fixes JabRef#13684
@omkarrr2533 omkarrr2533 reopened this Dec 12, 2025
@github-actions github-actions bot added the good second issue Issues that involve a tour of two or three interweaved components in JabRef label Dec 12, 2025
@github-actions
Copy link
Contributor

This pull requests was closed without merging. You have been unassigned from the respective issue #13684.

@koppor
Copy link
Member

koppor commented Dec 12, 2025

@omkarrr2533 Please either keep the PR open and work on the task - or keep it closed and move on. Please do not play an open-/close game with our bots.

@omkarrr2533 omkarrr2533 reopened this Dec 12, 2025
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 13, 2025
Refactor group merging logic and improve UI refresh handling after import.
@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 13, 2025
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 13, 2025
@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 13, 2025
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 13, 2025
@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 13, 2025
@jabref-machine
Copy link
Collaborator

Your code currently does not meet JabRef's code guidelines. IntelliJ auto format covers some cases. There seem to be issues with your code style and autoformat configuration. Please reformat your code (Ctrl+Alt+L) and commit, then push.

In special cases, consider using // formatter:off and // formatter:on annotations to allow deviation from the code style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: groups good second issue Issues that involve a tour of two or three interweaved components in JabRef status: changes-required Pull requests that are not yet complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Groups not visible in the vertical left bar even if correctly visibile in the groups field in each record

4 participants