mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-51838 autocomplete: Scroll the suggestions list
Keep the active item "visible" when using keyboard nav on a long list of suggestions.
This commit is contained in:
parent
9382ac38d6
commit
32f3de567f
2
lib/amd/build/form-autocomplete.min.js
vendored
2
lib/amd/build/form-autocomplete.min.js
vendored
File diff suppressed because one or more lines are too long
@ -133,6 +133,15 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
|
||||
element.attr('aria-selected', true).attr('id', itemId);
|
||||
// Tell the input field it has a new active descendant so the item is announced.
|
||||
inputElement.attr('aria-activedescendant', itemId);
|
||||
|
||||
// Scroll it into view.
|
||||
var scrollPos = element.offset().top
|
||||
- suggestionsElement.offset().top
|
||||
+ suggestionsElement.scrollTop()
|
||||
- (suggestionsElement.height() / 2);
|
||||
suggestionsElement.animate({
|
||||
scrollTop: scrollPos
|
||||
}, 100);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user