diff --git a/Packages/ohif-measurements/client/components/measureFlow/measureFlow.js b/Packages/ohif-measurements/client/components/measureFlow/measureFlow.js index 0c3a373d0..16665fc66 100644 --- a/Packages/ohif-measurements/client/components/measureFlow/measureFlow.js +++ b/Packages/ohif-measurements/client/components/measureFlow/measureFlow.js @@ -83,7 +83,10 @@ Template.measureFlow.onRendered(() => { instance.$('.btn-add').focus(); if (instance.data.autoClick) { - instance.$('.btn-add').hide().trigger('click'); + instance.$('.btn-add').hide().trigger('click', { + clientX: instance.data.position.x, + clientY: instance.data.position.Y + }); } }); @@ -100,11 +103,19 @@ Template.measureFlow.events({ // Wait template rerender before rendering the selectTree Tracker.afterFlush(() => { - // Get the click position - const position = { - left: event.clientX, - top: event.clientY, - }; + // Get the click or rendering position + let position; + if (_.isUndefined(event.clientX)) { + position = { + left: instance.data.position.x, + top: instance.data.position.y, + }; + } else { + position = { + left: event.clientX, + top: event.clientY, + }; + } // Define the data for selectTreeComponent const data = { @@ -235,6 +246,8 @@ Template.measureFlow.events({ // Reset the flag to avoid wrong positioning when clicking normal labels again instance.commonClicked = false; + + instance.data.updateCallback(instance.value.value, instance.description.get()); }); // Wait the fade-out transition and remove the selectTree component @@ -262,8 +275,6 @@ Template.measureFlow.events({ 'close .measure-flow'(event, instance) { const $measureFlow = $(event.currentTarget); - $measureFlow.one('animationend', () => { - instance.data.doneCallback(instance.value.value, instance.description.get()); - }).addClass('fadeOut'); + $measureFlow.one('animationend', instance.data.doneCallback).addClass('fadeOut'); } }); diff --git a/Packages/ohif-measurements/client/lib/toggleLabelButton.js b/Packages/ohif-measurements/client/lib/toggleLabelButton.js index 71d1fc811..a7f2978ef 100644 --- a/Packages/ohif-measurements/client/lib/toggleLabelButton.js +++ b/Packages/ohif-measurements/client/lib/toggleLabelButton.js @@ -31,11 +31,8 @@ OHIF.measurements.toggleLabelButton = options => { threeColumns: true, hideCommon: true, autoClick: options.autoClick, - doneCallback(location, description) { - if (_.isFunction(options.callback)) { - options.callback(options, location, description); - } - + doneCallback: removeButtonView, + updateCallback(location, description) { toolCollection.update({ measurementNumber: measurement.measurementNumber, toolType: measurement.toolType, @@ -48,8 +45,6 @@ OHIF.measurements.toggleLabelButton = options => { }, { multi: true }); - - removeButtonView(); } }; const view = Blaze.renderWithData(Template.measureFlow, data, options.element);