JS: Focus the element referenced by the anchor on anchor navigation ...
... instead of looking for any heading.
This commit is contained in:
parent
77b99552a4
commit
8b7250bfa6
|
@ -364,21 +364,8 @@
|
|||
handleAnchor: function(query) {
|
||||
var $element = $(query);
|
||||
if ($element.length > 0) {
|
||||
// Try to find the first header. It is more pleasant to users
|
||||
// to select the header instead a container
|
||||
var $header = $element.find(':header:first');
|
||||
if ($header.length > 0) {
|
||||
$element = $header;
|
||||
} else {
|
||||
var $input = $element.find(':header:first');
|
||||
if ($input.length > 0) {
|
||||
$element = $input
|
||||
}
|
||||
}
|
||||
// If we want to focus an element which has no tabindex
|
||||
// add one that we can focus is
|
||||
if ($element.prop('tabindex') < 0) {
|
||||
$element.prop('tabindex', 0);
|
||||
if (typeof $element.attr('tabindex') === 'undefined') {
|
||||
$element.attr('tabindex', -1);
|
||||
}
|
||||
$element.focus();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue