mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-16 18:55:40 -04:00
Handle user clicking on child element of list item (#1322)
This commit is contained in:
parent
a8cab597c8
commit
f37ed3c1c1
@ -2041,12 +2041,25 @@ function populateListOfArticles (dirEntryArray, reportingSearch) {
|
|||||||
/**
|
/**
|
||||||
* Handles the click on the title of an article in search results
|
* Handles the click on the title of an article in search results
|
||||||
* @param {Event} event The click event to handle
|
* @param {Event} event The click event to handle
|
||||||
* @returns {Boolean} Always returns false for JQuery event handling
|
|
||||||
*/
|
*/
|
||||||
function handleTitleClick (event) {
|
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);
|
findDirEntryFromDirEntryIdAndLaunchArticleRead(dirEntryId);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user