Skip to content

Commit 2a74355

Browse files
igoroctavianodannyrb
authored andcommitted
fix: 🐛 set current viewport as active when switching layouts (#1018)
* fix: 🐛 set current viewport as active when switching layouts check if current viewport index is less than the current layout lenght and set 0 if so or keep current selected cell index as active viewport Closes: 999 * chore: 🤖 commenting out docker layer caching in the short-term commenting out docker layer caching in the short-term * refactor: 💡 refactor layout matrix index conditional
1 parent a28984e commit 2a74355

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ jobs:
142142
steps:
143143
- attach_workspace:
144144
at: ~/repo
145-
- setup_remote_docker:
146-
docker_layer_caching: true
145+
# - setup_remote_docker:
146+
# docker_layer_caching: true
147147
- run:
148148
name: Build and push Docker image
149149
command: |
@@ -198,8 +198,8 @@ jobs:
198198
steps:
199199
- attach_workspace:
200200
at: ~/repo
201-
- setup_remote_docker:
202-
docker_layer_caching: true
201+
# - setup_remote_docker:
202+
# docker_layer_caching: true
203203
- run:
204204
name: Deploy latest version to viewer.ohif.org
205205
command: |

platform/viewer/src/connectedComponents/ConnectedLayoutButton.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ import { LayoutButton } from '@ohif/ui';
22
import OHIF from '@ohif/core';
33
import { connect } from 'react-redux';
44

5-
const { setLayout } = OHIF.redux.actions;
5+
const { setLayout, setViewportActive } = OHIF.redux.actions;
66

77
const mapStateToProps = state => {
88
return {
99
currentLayout: state.viewports.layout,
10+
activeViewportIndex: state.viewports.activeViewportIndex
1011
};
1112
};
1213

1314
const mapDispatchToProps = dispatch => {
1415
return {
1516
// TODO: Change if layout switched becomes more complex
16-
onChange: (selectedCell, currentLayout) => {
17+
onChange: (selectedCell, currentLayout, activeViewportIndex) => {
1718
let viewports = [];
1819
const rows = selectedCell.row + 1;
1920
const columns = selectedCell.col + 1;
@@ -36,17 +37,22 @@ const mapDispatchToProps = dispatch => {
3637
viewports,
3738
};
3839

40+
const maxActiveIndex = rows * columns - 1;
41+
if (activeViewportIndex > maxActiveIndex) {
42+
dispatch(setViewportActive(0));
43+
}
44+
3945
dispatch(setLayout(layout));
4046
},
4147
};
4248
};
4349

4450
const mergeProps = (propsFromState, propsFromDispatch) => {
4551
const onChangeFromDispatch = propsFromDispatch.onChange;
46-
const { currentLayout } = propsFromState;
52+
const { currentLayout, activeViewportIndex } = propsFromState;
4753

4854
return {
49-
onChange: (selectedCell) => onChangeFromDispatch(selectedCell, currentLayout)
55+
onChange: selectedCell => onChangeFromDispatch(selectedCell, currentLayout, activeViewportIndex)
5056
};
5157
}
5258

0 commit comments

Comments
 (0)