Skip to content

Commit 29e4f2d

Browse files
committed
fix(windowing): fix range manipulator corrupting windowing
If mouse range manipulator sent just a level or width while windowing config state is on auto, we would go to default level/width instead of keeping the current one defined by auto
1 parent 89f8ba1 commit 29e4f2d

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/store/view-configs/windowing.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export const useWindowingStore = defineStore('windowing', () => {
100100
const defaults = defaultWindowLevelConfig();
101101

102102
let effectiveUseAuto = currentInternalConfig?.useAuto ?? defaults.useAuto;
103+
let widthLevelPatchOnSwitchingFromAuto;
103104

104105
if (patch.useAuto !== undefined) {
105106
effectiveUseAuto = patch.useAuto;
@@ -109,14 +110,23 @@ export const useWindowingStore = defineStore('windowing', () => {
109110
if (patch.useAuto === undefined) {
110111
effectiveUseAuto = false;
111112
}
113+
if (!effectiveUseAuto) {
114+
// patch may be only width or level so ensure we have both in the end
115+
const config = getConfig(viewID, dataID).value;
116+
if (config) {
117+
widthLevelPatchOnSwitchingFromAuto = {
118+
width: config.width,
119+
level: config.level,
120+
};
121+
}
122+
}
112123
}
113124

114-
const newInternalConfig: WindowLevelConfig = {
115-
...defaults,
116-
...(currentInternalConfig ?? {}),
125+
const newInternalConfig = {
126+
...widthLevelPatchOnSwitchingFromAuto,
117127
...patch,
118128
useAuto: effectiveUseAuto,
119-
userTriggered: currentInternalConfig?.userTriggered || userTriggered,
129+
userTriggered: currentInternalConfig?.userTriggered || userTriggered, // one way from false to true
120130
};
121131

122132
patchDoubleKeyRecord(configs, viewID, dataID, newInternalConfig);

0 commit comments

Comments
 (0)