fix: set focus on target after clicking anchor (#35446)

This commit is contained in:
Jansen Kantor
2024-09-09 12:00:07 -04:00
committed by GitHub
parent e498d2087d
commit fbd7d4ca4c

View File

@@ -144,10 +144,12 @@ ${HTML(fragment.foot_html())}
// to stay in relatively the same position so viewing of the video
// is not disrupted.
if ($(this).attr('class') === 'transcript-start'||$(this).attr('class') === 'transcript-end') {
var target = $(targetId)[0];
event.preventDefault();
$(targetId)[0].scrollIntoView({
target.scrollIntoView({
block: 'nearest',
});
target.focus();
} else {
var targetName = $(this).attr('href').slice(1);
// Checks if the target uses an id or name.
@@ -159,6 +161,7 @@ ${HTML(fragment.foot_html())}
target.scrollIntoView({
block: 'start',
});
target.focus();
}
}
}