h5p-course-presentation
h5p-course-presentation copied to clipboard
Is the target correctly defined?
https://github.com/h5p/h5p-course-presentation/blob/2c2a6d107947b58008b35c35cd7bcf891b470c38/src/scripts/cp.js#L234
Shouldn't it be H5P.jQuery(event.currentTarget)
instead of H5P.jQuery(event.target)
?
@cornelles, I don't think so.. could you elaborate?
Actually my problem is the next part of the code
if (!$target.is('input, textarea, a') && !that.editor) {
// Add focus to the wrapper so that it may capture keyboard events
that.$wrapper.focus();
}
this one introduced "a" tag along the "input" and "textarea".
The main idea is that I have a listener on the anchor inside a CP that will scroll to a different part of the page and the code above gets executed after I scroll to the content of the page and refocus on the clicked item.
In my case it was a "span" inside the anchor because font-size has been used on the anchor, so event.target
is returning the span not the anchor, this condition is not met !$target.is('input, textarea, a')
and that's why is repositioning the page to the clicked content.
If you look at event.currentTarget
that will contain the anchor that has been clicked and then the page will not get refocused.
That seems to make sense, the auto-scrolling should take into account elements which have events attached not just the ones that are clicked:
https://stackoverflow.com/questions/10086427/what-is-the-exact-difference-between-currenttarget-property-and-target-property
I've created an issue for it to be investigated further:
https://h5ptechnology.atlassian.net/browse/HFP-1772