Skip to content

Commit

Permalink
UI: Fix overlapping click event handler (wekan#614)
Browse files Browse the repository at this point in the history
The click event handler for links in the card display are overlapping:
The general event for opening the link in a new window matches on user
mentions, too. But user mentions cannot be opened in a new window.
  • Loading branch information
AlexanderS authored and mquandalle committed Jul 11, 2016
1 parent 3f12e3e commit 36f17a5
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions client/components/main/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,27 @@ Blaze.Template.registerHelper('mentions', new Template('mentions', function() {
}));

Template.viewer.events({
'click .js-open-member'(evt, tpl) {
const userId = evt.currentTarget.dataset.userid;
Popup.open('member').call({ userId }, evt, tpl);
},

// Viewer sometimes have click-able wrapper around them (for instance to edit
// the corresponding text). Clicking a link shouldn't fire these actions, stop
// we stop these event at the viewer component level.
'click a'(evt) {
'click a'(evt, tpl) {
evt.stopPropagation();

// XXX We hijack the build-in browser action because we currently don't have
// `_blank` attributes in viewer links, and the transformer function is
// handled by a third party package that we can't configure easily. Fix that
// by using directly `_blank` attribute in the rendered HTML.
evt.preventDefault();
const href = evt.currentTarget.href;
if (href) {
window.open(href, '_blank');

const userId = evt.currentTarget.dataset.userid;
if (userId) {
Popup.open('member').call({ userId }, evt, tpl);
}
else {
const href = evt.currentTarget.href;
if (href) {
window.open(href, '_blank');
}
}
},
});

0 comments on commit 36f17a5

Please sign in to comment.