Update code to avoid intercepting onclick
This commit is contained in:
1 parent
911f93d378
commit
3f0619848b
3 files changed
+19
-16
No files matched your search
@@ -58,9 +58,9 @@ function ViewerLayout({
|
||||
const defaultTool = { icon: 'tool-more-menu', label: 'More' };
|
||||
const [toolbars, setToolbars] = useState({ primary: [], secondary: [] });
|
||||
const [activeTool, setActiveTool] = useState(defaultTool);
|
||||
const onSecondaryClickHandler = () => setActiveTool(defaultTool);
|
||||
const onPrimaryClickHandler = (evt, btn) => {
|
||||
setActiveTool(btn.props.isActive ? btn.props : defaultTool);
|
||||
|
||||
const setActiveToolHandler = (tool, isNested) => {
|
||||
setActiveTool(isNested ? tool : defaultTool);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -69,8 +69,8 @@ function ViewerLayout({
|
||||
() => {
|
||||
console.warn('~~~ TOOL BAR MODIFIED EVENT CAUGHT');
|
||||
const updatedToolbars = {
|
||||
primary: ToolBarService.getButtonSection('primary', { onClick: onPrimaryClickHandler }),
|
||||
secondary: ToolBarService.getButtonSection('secondary', { onClick: onSecondaryClickHandler }),
|
||||
primary: ToolBarService.getButtonSection('primary', { setActiveTool: setActiveToolHandler }),
|
||||
secondary: ToolBarService.getButtonSection('secondary', { setActiveTool: setActiveToolHandler }),
|
||||
};
|
||||
setToolbars(updatedToolbars);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export default function getToolbarModule({ commandsManager, servicesManager }) {
|
||||
{
|
||||
name: 'ohif.divider',
|
||||
defaultComponent: ToolbarDivider,
|
||||
clickHandler: () => {},
|
||||
clickHandler: () => { },
|
||||
},
|
||||
{
|
||||
name: 'ohif.action',
|
||||
@@ -30,7 +30,7 @@ export default function getToolbarModule({ commandsManager, servicesManager }) {
|
||||
optionalConfig: [],
|
||||
requiredProps: [],
|
||||
optionalProps: [],
|
||||
clickHandler: (evt, clickedBtn, btnSectionName) => {
|
||||
clickHandler: (evt, clickedBtn, btnSectionName, metadata, viewerProps) => {
|
||||
const { props } = clickedBtn;
|
||||
const allButtons = toolbarService.getButtons();
|
||||
|
||||
@@ -47,6 +47,10 @@ export default function getToolbarModule({ commandsManager, servicesManager }) {
|
||||
clickedBtn.config.groupName === btn.config.groupName
|
||||
) {
|
||||
btn.props.isActive = false;
|
||||
|
||||
if (viewerProps.setActiveTool) {
|
||||
viewerProps.setActiveTool(props, metadata.isNested);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -63,7 +67,7 @@ export default function getToolbarModule({ commandsManager, servicesManager }) {
|
||||
{
|
||||
name: 'ohif.layoutSelector',
|
||||
defaultComponent: ToolbarLayoutSelector,
|
||||
clickHandler: (evt, clickedBtn, btnSectionName) => {},
|
||||
clickHandler: (evt, clickedBtn, btnSectionName) => { },
|
||||
},
|
||||
{
|
||||
name: 'ohif.toggle',
|
||||
|
||||
Reference in new issue
Block a user