From edc92f7747dc13a9671fff4cbe351665ff625208 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 30 Jun 2022 22:12:24 -0400 Subject: [PATCH] crmUi - Fix crmPageTitle directive to work inside a modal --- ang/crmUi.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/ang/crmUi.js b/ang/crmUi.js index 11eb5e28ef..3e3132cae1 100644 --- a/ang/crmUi.js +++ b/ang/crmUi.js @@ -1097,21 +1097,27 @@ $timeout(function() { var newPageTitle = _.trim($el.html()), newDocumentTitle = scope.crmDocumentTitle || $el.text(), - h1Count = 0; - document.title = $('title').text().replace(documentTitle, newDocumentTitle); - // If the CMS has already added title markup to the page, use it - $('h1').not('.crm-container h1').each(function() { - if ($(this).hasClass('crm-page-title') || _.trim($(this).html()) === pageTitle) { - $(this).addClass('crm-page-title').html(newPageTitle); - $el.hide(); - ++h1Count; + h1Count = 0, + dialog = $el.closest('.ui-dialog-content'); + if (dialog.length) { + dialog.dialog('option', 'title', newDocumentTitle); + $el.hide(); + } else { + document.title = $('title').text().replace(documentTitle, newDocumentTitle); + // If the CMS has already added title markup to the page, use it + $('h1').not('.crm-container h1').each(function () { + if ($(this).hasClass('crm-page-title') || _.trim($(this).html()) === pageTitle) { + $(this).addClass('crm-page-title').html(newPageTitle); + $el.hide(); + ++h1Count; + } + }); + if (!h1Count) { + $el.show(); } - }); - if (!h1Count) { - $el.show(); + pageTitle = newPageTitle; + documentTitle = newDocumentTitle; } - pageTitle = newPageTitle; - documentTitle = newDocumentTitle; }); } -- 2.25.1