Bolding text inside a link in task title/notes. (#12178) (#12195)

* Bolding text inside a link in task title/notes. (#12178)

Before:
* link target opened in new tab
* task edit popup opened

Now:
* link target opened in new tab

Fixes #12178

* Handle PR comments

* Added explanation
* Switched to classList to improve readability
This commit is contained in:
Frank Maximus
2020-05-19 16:55:43 +02:00
committed by GitHub
parent ea44af0929
commit 1bc756ee93

View File

@@ -976,10 +976,18 @@ export default {
edit (e, task) {
if (this.isRunningYesterdailies || !this.showEdit) return;
// Prevent clicking on a link from opening the edit modal
const target = e.target || e.srcElement;
if (target.tagName === 'A') return; // clicked on a link
/*
* Prevent clicking on a link from opening the edit modal
*
* Ascend up the ancestors of the click target, up until the node defining the click handler.
* If any of them is an <a> element, don't open the edit task popup.
* Needed in case of a link, with a bold and/or italic link description
*/
for (let element = target; !element.classList.contains('task-clickable-area'); element = element.parentNode) {
if (element.tagName === 'A') return; // clicked on a link
}
const isDropdown = this.$refs.taskDropdown && this.$refs.taskDropdown.$el.contains(target);
const isEditAction = this.$refs.editTaskItem && this.$refs.editTaskItem.contains(target);