From 50374038a3c8a43bc3045706c4bc438d024e5eeb Mon Sep 17 00:00:00 2001 From: Bruno Alves de Faria Date: Tue, 10 Apr 2018 16:04:14 -0300 Subject: [PATCH] fix(modals) Fixing DOM issues with modals --- .../components/bootstrap/dialog/confirm.html | 6 +++--- .../components/bootstrap/dialog/simple.js | 6 ++++-- Packages/ohif-core/client/ui/dialog/display.js | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Packages/ohif-core/client/components/bootstrap/dialog/confirm.html b/Packages/ohif-core/client/components/bootstrap/dialog/confirm.html index 9d82c3e98..57baa6518 100644 --- a/Packages/ohif-core/client/components/bootstrap/dialog/confirm.html +++ b/Packages/ohif-core/client/components/bootstrap/dialog/confirm.html @@ -1,7 +1,7 @@ diff --git a/Packages/ohif-core/client/components/bootstrap/dialog/simple.js b/Packages/ohif-core/client/components/bootstrap/dialog/simple.js index b4ca7ba60..2ca4c4e61 100644 --- a/Packages/ohif-core/client/components/bootstrap/dialog/simple.js +++ b/Packages/ohif-core/client/components/bootstrap/dialog/simple.js @@ -7,8 +7,7 @@ Template.dialogSimple.onCreated(() => { const instance = Template.instance(); instance.close = () => { - const $modal = instance.$('.modal'); - $modal.one('hidden.bs.modal', () => instance.data.promiseResolve()).modal('hide'); + instance.$('.modal').modal('hide'); }; // Automatically close the modal if a timeout value was given @@ -31,6 +30,9 @@ Template.dialogSimple.onRendered(() => { // Create the bootstrap modal $modal.modal(modalOptions); + // Resolve the promise as soon as the modal is closed + $modal.one('hidden.bs.modal', () => instance.data.promiseResolve()); + let position = instance.data.position; const { event } = instance.data; diff --git a/Packages/ohif-core/client/ui/dialog/display.js b/Packages/ohif-core/client/ui/dialog/display.js index 9f30104b6..810e77d6e 100644 --- a/Packages/ohif-core/client/ui/dialog/display.js +++ b/Packages/ohif-core/client/ui/dialog/display.js @@ -4,6 +4,9 @@ import { _ } from 'meteor/underscore'; import { $ } from 'meteor/jquery'; import { OHIF } from 'meteor/ohif:core'; +let zIndexBackdrop = 1060; +let zIndexModal = 1061; + OHIF.ui.showDialog = (templateName, dialogData={}) => { // Check if the given template exists const template = Template[templateName]; @@ -49,6 +52,20 @@ OHIF.ui.showDialog = (templateName, dialogData={}) => { $modal = $node.find('.modal:first'); } + $modal.one('show.bs.modal', function() { + setTimeout(() => { + const $modal = $(this); + const modal = $modal.data('bs.modal'); + if (!modal) return; + const { $backdrop } = modal; + if (!$backdrop) return; + $backdrop.css('z-index', zIndexBackdrop); + $modal.css('z-index', zIndexModal); + zIndexBackdrop += 2; + zIndexModal += 2; + }); + }); + // Destroy the created dialog view when the promise is either resolved or rejected const dismissModal = (hideFirst=false) => { if (hideFirst || (dialogData && dialogData.promise && $modal)) {