From 32f3de567ff21e6c53f3bd5552123a0b9ebf02cb Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Mon, 26 Oct 2015 12:20:33 +0800 Subject: [PATCH] MDL-51838 autocomplete: Scroll the suggestions list Keep the active item "visible" when using keyboard nav on a long list of suggestions. --- lib/amd/build/form-autocomplete.min.js | 2 +- lib/amd/src/form-autocomplete.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/amd/build/form-autocomplete.min.js b/lib/amd/build/form-autocomplete.min.js index fa29639cfc2..d057151f3a9 100644 --- a/lib/amd/build/form-autocomplete.min.js +++ b/lib/amd/build/form-autocomplete.min.js @@ -1 +1 @@ -define(["jquery","core/log","core/str","core/templates","core/notification"],function(a,b,c,d,e){var f={DOWN:40,ENTER:13,SPACE:32,ESCAPE:27,COMMA:188,UP:38},g=null,h=function(b,c){var d=a(document.getElementById(c)),e=d.children("[aria-selected=true]").length;for(b%=e;0>b;)b+=e;var f=a(d.children("[aria-selected=true]").get(b)),g=c+"-"+b;d.children().attr("data-active-selection",!1).attr("id",""),f.attr("data-active-selection",!0).attr("id",g),d.attr("aria-activedescendant",g)},i=function(b,c,d,e,f){var g=a(d).attr("data-value");f&&e.children("option").each(function(b,c){a(c).attr("value")==g&&a(c).prop("selected",!1)}),r(c,b,e,f)},j=function(b,c,d){var e=a(document.getElementById(c)),f=a(document.getElementById(d)),g=f.children("[aria-hidden=false]").length;for(b%=g;0>b;)b+=g;var h=a(f.children("[aria-hidden=false]").get(b)),i=a(f.children("[role=option]")).index(h),j=d+"-"+i;f.children().attr("aria-selected",!1).attr("id",""),h.attr("aria-selected",!0).attr("id",j),e.attr("aria-activedescendant",j)},k=function(b,c){var d=a(document.getElementById(c)),e=d.children("[aria-selected=true]"),f=d.children("[aria-hidden=false]").index(e);j(f+1,b,c)},l=function(b){var c=a(document.getElementById(b)),d=c.children("[data-active-selection=true]");if(!d)return void h(0,b);var e=c.children("[aria-selected=true]").index(d);h(e-1,b)},m=function(b){var c=a(document.getElementById(b)),d=c.children("[data-active-selection=true]");if(!d)return void h(0,b);var e=c.children("[aria-selected=true]").index(d);h(e+1,b)},n=function(b,c){var d=a(document.getElementById(c)),e=d.children("[aria-selected=true]"),f=d.children("[aria-hidden=false]").index(e);j(f-1,b,c)},o=function(b,c,d){var e=a(document.getElementById(b)),f=a(document.getElementById(c));e.attr("aria-expanded",!1).attr("aria-activedescendant",d),f.hide().attr("aria-hidden",!0)},p=function(b,c,f,g,h,i){var k=a(document.getElementById(c)),l=a(document.getElementById(f)),m=!1,n=[];g.children("option").each(function(b,c){a(c).prop("selected")!==!0&&(n[n.length]={label:c.innerHTML,value:a(c).attr("value")})}),d.render("core/form_autocomplete_suggestions",{inputId:c,suggestionsId:f,options:n,multiple:h}).done(function(d){l.replaceWith(d),l=a(document.getElementById(f)),l.show().attr("aria-hidden",!1),l.children().each(function(c,d){d=a(d),d.text().indexOf(b)>-1?(d.show().attr("aria-hidden",!1),m=!0):d.hide().attr("aria-hidden",!0)}),m?(k.attr("aria-expanded",!0),i||j(0,c,f)):(l.hide(),l.attr("aria-hidden",!0),k.attr("aria-expanded",!1))}).fail(e.exception)},q=function(b,c,f,g,h){var i=a(document.getElementById(b)),j=i.val(),k=j.split(","),l=!1;a.each(k,function(b,c){if(c=c.trim(),""!==c&&(g||h.children("option").prop("selected",!1),h.children("option").each(function(b,d){a(d).attr("value")==c&&(l=!0,a(d).prop("selected",!0))}),!l)){var d=a("