Skip to content

Commit

Permalink
Merge pull request #62 from studio24/hotfix/cards-click-handler
Browse files Browse the repository at this point in the history
fix: Handle click modifiers on cards
  • Loading branch information
NicolaSaunders authored Jan 30, 2024
2 parents bc695f5 + c01b2b6 commit d6e0c6f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
12 changes: 9 additions & 3 deletions assets-src/js/main/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ var cardEnhancement = function () {
});
}

card.addEventListener('click', function() {
var noTextSelected = !window.getSelection().toString();
card.addEventListener('click', function(event) {
if (event.redispatched || event.target === mainLink) {
return;
}

let noTextSelected = !window.getSelection().toString();

if (noTextSelected) {
mainLink.click();
const event2 = new MouseEvent("click", event);
event2.redispatched = true;
mainLink.dispatchEvent(event2);
}
});
});
Expand Down
9 changes: 7 additions & 2 deletions web/dist/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ var cardEnhancement = function cardEnhancement() {
});
});
}
card.addEventListener('click', function () {
card.addEventListener('click', function (event) {
if (event.redispatched || event.target === mainLink) {
return;
}
var noTextSelected = !window.getSelection().toString();
if (noTextSelected) {
mainLink.click();
var event2 = new MouseEvent("click", event);
event2.redispatched = true;
mainLink.dispatchEvent(event2);
}
});
});
Expand Down
Loading

0 comments on commit d6e0c6f

Please sign in to comment.