Skip to content

Commit 4dd772e

Browse files
authored
Fix tool switching (#9153)
Pressing they keyboard shortcut W or Shift+W crashes WK. This PR fixes the tool switching. ### URL of deployed dev instance (used for testing): - https://___.webknossos.xyz ### Steps to test: - Open annotation - Press `W` - WK cycles through the tools without crashing ### Issues: - fixes #https://scm.slack.com/archives/C5AKLAV0B/p1765978379870339?thread_ts=1765963073.880699&cid=C5AKLAV0B ------ (Please delete unneeded items, merge only when none are left open) - [x] Added changelog entry (create a `$PR_NUMBER.md` file in `unreleased_changes` or use `./tools/create-changelog-entry.py`) - [ ] Added migration guide entry if applicable (edit the same file as for the changelog) - [ ] Updated [documentation](../blob/master/docs) if applicable - [ ] Adapted [wk-libs python client](https://github.com/scalableminds/webknossos-libs/tree/master/webknossos/webknossos/client) if relevant API parts change - [ ] Removed dev-only changes like prints and application.conf edits - [ ] Considered [common edge cases](../blob/master/.github/common_edge_cases.md) - [ ] Needs datastore update after deployment
1 parent 55fa4e9 commit 4dd772e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

frontend/javascripts/viewer/view/action-bar/tools/toolbar_view.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,12 @@ function MeasurementToolSwitch({ activeTool }: { activeTool: AnnotationTool }) {
240240
const { isDisabled, explanation } = disabledInfosForTools[AnnotationTool.AREA_MEASUREMENT.id];
241241

242242
const handleSetMeasurementTool = (evt: RadioChangeEvent) => {
243-
dispatch(setToolAction(evt.target.value));
243+
const value = evt.target.value as AnnotationToolId;
244+
dispatch(setToolAction(AnnotationTool[value]));
244245
};
245246
return (
246247
<Radio.Group
247-
value={activeTool}
248+
value={activeTool.id}
248249
onChange={handleSetMeasurementTool}
249250
style={{
250251
marginLeft: 10,
@@ -253,7 +254,7 @@ function MeasurementToolSwitch({ activeTool }: { activeTool: AnnotationTool }) {
253254
<RadioButtonWithTooltip
254255
title="Measure distances with connected lines by using Left Click."
255256
style={NARROW_BUTTON_STYLE}
256-
value={AnnotationTool.LINE_MEASUREMENT}
257+
value={AnnotationTool.LINE_MEASUREMENT.id}
257258
>
258259
<img src="/assets/images/line-measurement.svg" alt="Measurement Tool Icon" />
259260
</RadioButtonWithTooltip>
@@ -263,7 +264,7 @@ function MeasurementToolSwitch({ activeTool }: { activeTool: AnnotationTool }) {
263264
"Measure areas by using Left Drag. Avoid self-crossing polygon structure for accurate results."
264265
}
265266
style={NARROW_BUTTON_STYLE}
266-
value={AnnotationTool.AREA_MEASUREMENT}
267+
value={AnnotationTool.AREA_MEASUREMENT.id}
267268
disabled={isDisabled}
268269
>
269270
<img

unreleased_changes/9153.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Fixed
2+
- Fixed a crash when switching tools with keyboard shortcuts W and Shift + W

0 commit comments

Comments
 (0)