From cf7b08d03408a866822f7f7878df8452c886d445 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 2 May 2016 11:50:40 -0400 Subject: [PATCH] FIX: Middle clicking on search should open it in a new tab --- .../javascripts/discourse/widgets/header.js.es6 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/widgets/header.js.es6 b/app/assets/javascripts/discourse/widgets/header.js.es6 index 3f74ad212e3..711aef6dcfc 100644 --- a/app/assets/javascripts/discourse/widgets/header.js.es6 +++ b/app/assets/javascripts/discourse/widgets/header.js.es6 @@ -2,6 +2,7 @@ import { createWidget } from 'discourse/widgets/widget'; import { iconNode } from 'discourse/helpers/fa-icon'; import { avatarImg } from 'discourse/widgets/post'; import DiscourseURL from 'discourse/lib/url'; +import { wantsNewWindow } from 'discourse/lib/intercept-click'; import { h } from 'virtual-dom'; @@ -11,6 +12,7 @@ const dropdown = { }, click(e) { + if (wantsNewWindow(e)) { return; } e.preventDefault(); if (!this.attrs.active) { this.sendWidgetAction(this.attrs.action); @@ -43,7 +45,7 @@ createWidget('header-notifications', { } }); -createWidget('user-dropdown', jQuery.extend(dropdown, { +createWidget('user-dropdown', jQuery.extend({ tagName: 'li.header-dropdown-toggle.current-user', buildId() { @@ -56,9 +58,9 @@ createWidget('user-dropdown', jQuery.extend(dropdown, { return h('a.icon', { attributes: { href: currentUser.get('path'), 'data-auto-route': true } }, this.attach('header-notifications', attrs)); } -})); +}, dropdown)); -createWidget('header-dropdown', jQuery.extend(dropdown, { +createWidget('header-dropdown', jQuery.extend({ tagName: 'li.header-dropdown-toggle', html(attrs) { @@ -69,13 +71,13 @@ createWidget('header-dropdown', jQuery.extend(dropdown, { body.push(attrs.contents.call(this)); } - return h('a.icon', { attributes: { href: '', + return h('a.icon', { attributes: { href: attrs.href, 'data-auto-route': true, title, 'aria-label': title, id: attrs.iconId } }, body); } -})); +}, dropdown)); createWidget('header-icons', { tagName: 'ul.icons.clearfix',