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 broken context menu in dataset-view-mode when no segmentation layer is visible #6259

Merged
merged 3 commits into from
Jun 7, 2022
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 @@ -18,6 +18,7 @@ Added a warning for when the resolution in the XY viewport on z=1-downsampled da


### Fixed
- Fixed that the context menu broke webKnossos when opening it in dataset-view-mode while no segmentation layer was visible. [#6259](https://github.com/scalableminds/webknossos/pull/6259)

### Removed

Expand Down
16 changes: 5 additions & 11 deletions frontend/javascripts/oxalis/view/context_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,13 @@ function NodeContextMenuOptions({
volumeTracing,
infoRows,
allowUpdate,
}: NodeContextMenuOptionsProps) {
}: NodeContextMenuOptionsProps): JSX.Element {
const dispatch = useDispatch();

if (skeletonTracing == null) {
return null;
throw new Error(
"NodeContextMenuOptions should not have been called without existing skeleton tracing.",
);
}

const { userBoundingBoxes } = skeletonTracing;
Expand Down Expand Up @@ -613,7 +615,7 @@ function getBoundingBoxMenuOptions({
];
}

function NoNodeContextMenuOptions(props: NoNodeContextMenuProps) {
function NoNodeContextMenuOptions(props: NoNodeContextMenuProps): JSX.Element {
const {
skeletonTracing,
volumeTracing,
Expand Down Expand Up @@ -799,10 +801,6 @@ function NoNodeContextMenuOptions(props: NoNodeContextMenuProps) {
allActions = nonSkeletonActions.concat(skeletonActions).concat(boundingBoxActions);
}

if (allActions.length === 0) {
return null;
}

return (
<Menu
onClick={hideContextMenu}
Expand Down Expand Up @@ -888,7 +886,6 @@ function ContextMenuInner(propsWithInputRef: PropsWithRef) {
const { inputRef, ...props } = propsWithInputRef;
const {
skeletonTracing,
activeTool,
maybeClickedNodeId,
contextMenuPosition,
hideContextMenu,
Expand Down Expand Up @@ -1000,7 +997,6 @@ function ContextMenuInner(propsWithInputRef: PropsWithRef) {
// for the following two expressions, since this breaks
// antd's internal population of the correct class names
// for the menu.
// @ts-expect-error ts-migrate(2322) FIXME: Type 'Element | null' is not assignable to type 'E... Remove this comment to see the full error message
overlay =
maybeClickedNodeId != null
? NodeContextMenuOptions({
Expand All @@ -1010,8 +1006,6 @@ function ContextMenuInner(propsWithInputRef: PropsWithRef) {
...props,
})
: NoNodeContextMenuOptions({
// @ts-expect-error ts-migrate(2783) FIXME: 'activeTool' is specified more than once, so this ... Remove this comment to see the full error message
activeTool,
segmentIdAtPosition,
infoRows,
viewport: maybeViewport,
Expand Down