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

Fix deleting selected segments #7316

Merged
merged 2 commits into from
Sep 6, 2023
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.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Adapted Zarr 3 implementations to recent changes in the specification (index codecs, zstd codec). [#7305](https://github.com/scalableminds/webknossos/pull/7305)

### Fixed
- Fixed that the deletion of a selected segment would crash the segments tab. [#7316](https://github.com/scalableminds/webknossos/pull/7316)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,22 @@ class SegmentsView extends React.Component<Props, State> {
searchableTreeItemList.push(item);
});

const newSegmentIds = new Set(segments.map((segment) => segment.id));
const newGroupIds = new Set(segmentGroups.map((group) => group.groupId));
const oldSelectedGroupId = prevState.selectedIds.group;
updateStateObject = {
groupTree: generatedGroupTree,
searchableTreeItemList,
prevProps: nextProps,
selectedIds: {
// Ensure that the ids of previously selected segments are removed
// if these segments don't exist anymore.
segments: prevState.selectedIds.segments.filter((id) => newSegmentIds.has(id)),
group:
oldSelectedGroupId != null && newGroupIds.has(oldSelectedGroupId)
? oldSelectedGroupId
: null,
},
};
}
if (prevState.prevProps?.isosurfaces !== isosurfaces) {
Expand Down