mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-26 15:33:50 +00:00
Keep the focused item visible when navigating the search-to-add results with the arrow keys
This commit is contained in:
@@ -159,7 +159,17 @@ export function uiSearchAdd(context) {
|
||||
function focusListItem(selection) {
|
||||
if (!selection.empty()) {
|
||||
selection.classed('focused', true);
|
||||
//selection.nodes()[0].scrollIntoView();
|
||||
var node = selection.nodes()[0];
|
||||
var popoverNode = popover.node();
|
||||
var nodeRect = node.getBoundingClientRect();
|
||||
|
||||
// scroll to keep the focused item visible
|
||||
if (node.offsetTop < popoverNode.scrollTop) {
|
||||
popoverNode.scrollTop = node.offsetTop;
|
||||
|
||||
} else if (node.offsetTop + node.offsetHeight > popoverNode.scrollTop + popoverNode.offsetHeight) {
|
||||
popoverNode.scrollTop = node.offsetTop + node.offsetHeight - popoverNode.offsetHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user