Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed API key validation when saving a new or edited key. [#17012](https://github.com/JabRef/jabref/pull/17012)
- We fixed an issue where back navigation selected a deleted entry instead of skipping it. [#17353](https://github.com/JabRef/jabref/issues/17353)
- We fixed an issue where JabRef asked to store a library's custom entry types at every start. [#9930](https://github.com/JabRef/jabref/issues/9930)
- We fixed subgroups disappearing after adding them from the "All entries" context menu in a new library. [#17764](https://github.com/JabRef/jabref/issues/17764)
- We fixed an issue where group selections were lost when changing library tabs. [#1104](https://github.com/JabRef/jabref/issues/1104)
- We fixed obsolete group assignments remaining after changing an explicit group's grouping method. [#8824](https://github.com/JabRef/jabref/issues/8824)
- We fixed an issue where the AI chat tab still said "Unable to chat" after attaching a file. [#17157](https://github.com/JabRef/jabref/pull/17157)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,17 @@ public void addNewSubgroup(GroupNodeViewModel parent, GroupDialogHeader groupDia
null,
groupDialogHeader));

if (currentDatabase.filter(active -> active == database).isEmpty()) {
return;
}

// A context menu can still refer to the old "All entries" node after the tree is rebuilt.
GroupNodeViewModel currentParent = parent.isAllEntriesGroup() ? rootGroup.get() : parent;
newGroup.ifPresent(group -> recordTreeChange(Localization.lang("Add group"), _ -> {
GroupTreeNode newSubgroup = parent.addSubgroup(group);
GroupTreeNode newSubgroup = currentParent.addSubgroup(group);
// [impl->req~ux.groups.create-explicit-from-selection~1]
GroupNodeViewModel newViewModel = parent.findGroupNodeViewModel(newSubgroup)
.orElseGet(() -> new GroupNodeViewModel(database, stateManager, taskExecutor, newSubgroup, localDragboard, preferences));
GroupNodeViewModel newViewModel = currentParent.findGroupNodeViewModel(newSubgroup)
.orElseGet(() -> new GroupNodeViewModel(database, stateManager, taskExecutor, newSubgroup, localDragboard, preferences));
selectedGroups.setAll(newViewModel);

// TODO: expand the parent so the new group is visible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ void setUp() {
groupTree = new GroupTreeViewModel(stateManager, mock(BibEntryTypesManager.class), preferences, dialogService, mock(AiService.class), new CustomLocalDragboard(), taskExecutor);
}

@Test
void addSubgroupFromPreviousRootPersistsInCurrentTree() {
JavaFxExtension.invokeAndWait(() -> {
GroupNodeViewModel previousRoot = groupTree.rootGroupProperty().get();
databaseContext.getDatabase().insertEntry(new BibEntry());
activeDatabase.setValue(Optional.empty());
activeDatabase.setValue(Optional.of(databaseContext));

try (var ignored = mockConstruction(GroupDialogView.class)) {
when(dialogService.showCustomDialogAndWait(any(GroupDialogView.class)))
.thenReturn(Optional.of(new ExplicitGroup("a", GroupHierarchyType.INDEPENDENT, ',')));
groupTree.addNewSubgroup(previousRoot, GroupDialogHeader.SUBGROUP);
}
});

assertEquals(List.of("a"), childNames());
}

@Test
void rootGroupIsAllEntriesByDefault() {
AllEntriesGroup allEntriesGroup = new AllEntriesGroup("All entries");
Expand Down
Loading