Skip to content

Commit

Permalink
Fix broken context menu in dataset-view-mode when no segmentation lay…
Browse files Browse the repository at this point in the history
…er is visible (#6259)

* fix broken context menu in dataset-view-mode when no segmentation layer is visible

* update changelog
  • Loading branch information
philippotto committed Jun 7, 2022
1 parent 8ae68e4 commit 8993e3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
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
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

0 comments on commit 8993e3c

Please sign in to comment.