pawelczak / EasyAutocomplete

JQuery autocomplete plugin
http://easyautocomplete.com
MIT License
729 stars 243 forks source link

Accessibility issues (ADA) #270

Open shahul493 opened 7 years ago

shahul493 commented 7 years ago

Screen readers should know when the suggestions box open and closes. I have added ARIA tags to the container when we hide and show it. Please see the below fixes for this. Please commit this in your repo.

.on("show.eac", function() {

                        switch(config.get("list").showAnimation.type) {

                            case "slide":
                                var animationTime = config.get("list").showAnimation.time,
                                    callback = config.get("list").showAnimation.callback;

                                $elements_container.find("ul").slideDown(animationTime, callback);
                            break;

                            case "fade":
                                var animationTime = config.get("list").showAnimation.time,
                                    callback = config.get("list").showAnimation.callback;

                                $elements_container.find("ul").fadeIn(animationTime), callback;
                            break;

                            default:
                                $elements_container.find("ul").show();
                                $(".easy-autocomplete input").attr("aria-expanded","true");
                            break;
                        }

                        config.get("list").onShowListEvent();

                    })
                    /* List hide animation */
                    .on("hide.eac", function() {

                        switch(config.get("list").hideAnimation.type) {

                            case "slide":
                                var animationTime = config.get("list").hideAnimation.time,
                                    callback = config.get("list").hideAnimation.callback;

                                $elements_container.find("ul").slideUp(animationTime, callback);
                            break;

                            case "fade":
                                var animationTime = config.get("list").hideAnimation.time,
                                    callback = config.get("list").hideAnimation.callback;

                                $elements_container.find("ul").fadeOut(animationTime, callback);
                            break;

                            default:
                                $elements_container.find("ul").hide();
                                $(".easy-autocomplete input").attr("aria-expanded","false");
                            break;
                        }

                        config.get("list").onHideListEvent();

                    })
stephwestgarth commented 7 years ago

This should definitely be added. Usability for screen readers is important. I've done it via the options for now, but it should be built in.

shahul493 commented 7 years ago

Thank you!!