Skip to content

Commit 881346d

Browse files
authored
Merge pull request #1159 from Patternslib/fix-navigation-scrollmarker-click
fix(pat navigation): Fix current marker anchors with child elements.
2 parents f96e225 + 8578b1b commit 881346d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/pat/navigation/navigation.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ class Pattern extends BasePattern {
7070
"click",
7171
"pat_navigation_click_handler",
7272
(ev) => {
73-
if (ev.target.matches("a:not(.pat-inject)")) {
73+
// Get the click target's anchor element. The click target
74+
// might be a child of the link, e.g. a span wrapped within an
75+
// anchor.
76+
const target = ev.target.closest("a");
77+
if (target.matches(":not(.pat-inject)")) {
78+
7479
// Remove all set current classes
7580
this.clear_items();
7681
// Mark the current item
77-
this.mark_current(ev.target);
82+
this.mark_current(target);
7883

7984
if (
8085
!utils.is_option_truthy(this.options["scroll-trigger-selector"])

0 commit comments

Comments
 (0)