Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
fix(topstories): Ctrl-click/middle mouse button does not open new tab (
Browse files Browse the repository at this point in the history
  • Loading branch information
csadilek authored and Mardak committed Jul 31, 2017
1 parent d9d79b6 commit 2445903
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 5 additions & 1 deletion system-addon/content-src/components/Card/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ class Card extends React.Component {
}
onLinkClick(event) {
event.preventDefault();
this.props.dispatch(ac.SendToMain({type: at.OPEN_LINK, data: this.props.link}));
const {altKey, button, ctrlKey, metaKey, shiftKey} = event;
this.props.dispatch(ac.SendToMain({
type: at.OPEN_LINK,
data: Object.assign(this.props.link, {event: {altKey, button, ctrlKey, metaKey, shiftKey}})
}));
this.props.dispatch(ac.UserEvent({
event: "CLICK",
source: this.props.eventSource,
Expand Down
6 changes: 4 additions & 2 deletions system-addon/lib/PlacesFeed.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,12 @@ class PlacesFeed {
Pocket.savePage(action._target.browser, action.data.site.url, action.data.site.title);
break;
case at.OPEN_LINK: {
const win = action._target.browser.ownerGlobal;
const where = win.whereToOpenLink(action.data.event);
if (action.data.referrer) {
action._target.browser.loadURI(action.data.url, Services.io.newURI(action.data.referrer));
win.openLinkIn(action.data.url, where, {referrerURI: Services.io.newURI(action.data.referrer)});
} else {
action._target.browser.loadURI(action.data.url);
win.openLinkIn(action.data.url, where);
}
break;
}
Expand Down
12 changes: 6 additions & 6 deletions system-addon/test/unit/lib/PlacesFeed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,22 @@ describe("PlacesFeed", () => {
sinon.stub(feed, "openNewWindow");
const openLinkAction = {
type: at.OPEN_LINK,
data: {url: "foo.com"},
_target: {browser: {loadURI: sinon.spy()}}
data: {url: "foo.com", event: {where: "current"}},
_target: {browser: {ownerGlobal: {openLinkIn: sinon.spy(), whereToOpenLink: e => e.where}}}
};
feed.onAction(openLinkAction);
assert.calledWith(openLinkAction._target.browser.loadURI, openLinkAction.data.url);
assert.calledWith(openLinkAction._target.browser.ownerGlobal.openLinkIn, openLinkAction.data.url, "current");
});
it("should open link with referrer on OPEN_LINK", () => {
globals.set("Services", {io: {newURI: url => `URI:${url}`}});
sinon.stub(feed, "openNewWindow");
const openLinkAction = {
type: at.OPEN_LINK,
data: {url: "foo.com", referrer: "foo.com/ref"},
_target: {browser: {loadURI: sinon.spy()}}
data: {url: "foo.com", referrer: "foo.com/ref", event: {where: "tab"}},
_target: {browser: {ownerGlobal: {openLinkIn: sinon.spy(), whereToOpenLink: e => e.where}}}
};
feed.onAction(openLinkAction);
assert.calledWith(openLinkAction._target.browser.loadURI, openLinkAction.data.url, `URI:${openLinkAction.data.referrer}`);
assert.calledWith(openLinkAction._target.browser.ownerGlobal.openLinkIn, openLinkAction.data.url, "tab", {referrerURI: `URI:${openLinkAction.data.referrer}`});
});
it("should save to Pocket on SAVE_TO_POCKET", () => {
feed.onAction({type: at.SAVE_TO_POCKET, data: {site: {url: "raspberry.com", title: "raspberry"}}, _target: {browser: {}}});
Expand Down

0 comments on commit 2445903

Please sign in to comment.