Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core#1398: Option to open navigation item in new window (if present) #15861

Merged
merged 1 commit into from
Nov 25, 2019

Conversation

monishdeb
Copy link
Member

Overview

Currently, the target attribute of submenus are ignored whereas the menu item adds this property in the anchor links here

Before

The target attribute was ignored even if added using navigationMenu hook

After

The target atrribute is not ignored for (existing/new) sub-menu items

Comments

ping @colemanw @lcdservices @eileenmcnaughton

@civibot
Copy link

civibot bot commented Nov 15, 2019

(Standard links)

@civibot civibot bot added the master label Nov 15, 2019
@mlutfy
Copy link
Member

mlutfy commented Nov 15, 2019

jenkins, test this please

@@ -411,7 +411,7 @@
branchTpl:
'<% _.forEach(items, function(item) { %>' +
'<li <%= attr("li", item) %>>' +
'<a <%= attr("a", item) %>>' +
'<a <%= attr("a", item) %> <% if (item.target) { %>target=<%- item.target %><% } %>>' +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the attr() function, maybe instead of patching this line you could do this:

diff --git a/js/crm.menubar.js b/js/crm.menubar.js
index 152a6e376e..9fa49f63d6 100644
--- a/js/crm.menubar.js
+++ b/js/crm.menubar.js
@@ -471,7 +471,7 @@
   }
 
   function attr(el, item) {
-    var ret = [], attr = _.cloneDeep(item.attr || {}), a = ['rel', 'accesskey'];
+    var ret = [], attr = _.cloneDeep(item.attr || {}), a = ['rel', 'accesskey', 'target'];
     if (el === 'a') {
       attr = _.pick(attr, a);
       attr.href = item.url || "#";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monishdeb any thoughts?

@monishdeb
Copy link
Member Author

Thanks @colemanw for suggesting the tweak, about how we can use existing attr parameter to add target attribute to menus. I have submitted a doc PR civicrm/civicrm-dev-docs#734 to extend an example about how we can use the attr parameter to add anchor tag attributes (here target). Please have a look

@colemanw
Copy link
Member

Yes @monishdeb that looks right. Can you squash this PR please?

@monishdeb
Copy link
Member Author

done :)

@colemanw
Copy link
Member

FYI @monishdeb I tried to find where the function is used that you referenced in this PR description... and it's not. So I've filed #15956

@colemanw
Copy link
Member

Unrelated fail

@colemanw colemanw merged commit 6d90d8e into civicrm:master Nov 25, 2019
@monishdeb monishdeb deleted the core-1398 branch December 2, 2019 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants