Handle user clicking on child element of list item (#1322)

This commit is contained in:
Jaifroid 2025-03-23 14:31:15 +00:00 committed by GitHub
parent a8cab597c8
commit f37ed3c1c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2041,12 +2041,25 @@ function populateListOfArticles (dirEntryArray, reportingSearch) {
/**
* Handles the click on the title of an article in search results
* @param {Event} event The click event to handle
* @returns {Boolean} Always returns false for JQuery event handling
*/
function handleTitleClick (event) {
var dirEntryId = decodeURIComponent(event.target.getAttribute('dirEntryId'));
event.preventDefault();
// User may have clicked on a child element of the list item if it contains HTML (for example, italics),
// so we may need to find the closest list item
let target = event.target;
if (target.className !== 'list-group-item') {
console.warn('User clicked on child element of list item, looking for parent...');
while (target && target.className !== 'list-group-item') {
target = target.parentNode;
}
if (!target) {
// No list item found, so we can't do anything
console.warn('No list item could be found for clicked event!');
return;
}
}
var dirEntryId = decodeURIComponent(target.getAttribute('dirEntryId'));
findDirEntryFromDirEntryIdAndLaunchArticleRead(dirEntryId);
return false;
}
/**