Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add role="button" to chosen-single class link #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions coffee/chosen.jquery.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ class Chosen extends AbstractChosen
@container.addClass "chosen-dropup"

@container.addClass "chosen-with-drop"
@container.find(".chosen-single div").attr("aria-label", "Hide options")
@results_showing = true

@search_field.attr("aria-expanded", true)
Expand All @@ -313,6 +314,7 @@ class Chosen extends AbstractChosen

@container.removeClass "chosen-with-drop"
@container.removeClass "chosen-dropup"
@container.find(".chosen-single div").attr("aria-label", "Show options")
@form_field_jq.trigger("chosen:hiding_dropdown", {chosen: this})

@search_field.attr("aria-expanded", false)
Expand Down
4 changes: 3 additions & 1 deletion coffee/chosen.proto.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class @Chosen extends AbstractChosen
super()

# HTML Templates
@single_temp = new Template('<a class="chosen-single chosen-default"><span>#{default}</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" aria-expanded="false" aria-haspopup="true" role="combobox" aria-autocomplete="list" /></div><ul class="chosen-results" role="listbox" aria-busy="true"></ul></div>')
@single_temp = new Template('<a class="chosen-single chosen-default" role="button"><span>#{default}</span><div aria-label="Show options"><b aria-hidden="true"></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" aria-expanded="false" aria-haspopup="true" role="combobox" aria-autocomplete="list" /></div><ul class="chosen-results" role="listbox" aria-busy="true"></ul></div>')
@multi_temp = new Template('<ul class="chosen-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" aria-expanded="false" aria-haspopup="true" role="combobox" aria-autocomplete="list" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results" role="listbox" aria-busy="true"></ul></div>')
@no_results_temp = new Template('<li class="no-results">' + @results_none_found + ' "<span>#{terms}</span>"</li>')

Expand Down Expand Up @@ -296,6 +296,7 @@ class @Chosen extends AbstractChosen
@container.addClassName "chosen-dropup"

@container.addClassName "chosen-with-drop"
@container.find(".chosen-single div").attr("aria-label", "Hide options")
@results_showing = true

@search_field.writeAttribute("aria-expanded", "true")
Expand All @@ -317,6 +318,7 @@ class @Chosen extends AbstractChosen

@container.removeClassName "chosen-with-drop"
@container.removeClassName "chosen-dropup"
@container.find(".chosen-single div").attr("aria-label", "Show options")
@form_field.fire("chosen:hiding_dropdown", {chosen: this})

@search_field.writeAttribute("aria-expanded", "false")
Expand Down
4 changes: 2 additions & 2 deletions coffee/lib/abstract-chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ class AbstractChosen

get_single_html: ->
"""
<a class="chosen-single chosen-default">
<a class="chosen-single chosen-default" role="button">
<span>#{@default_text}</span>
<div><b></b></div>
<div aria-label="Show options"><b aria-hidden="true"></b></div>
</a>
<div class="chosen-drop">
<div class="chosen-search">
Expand Down
8 changes: 5 additions & 3 deletions docs/chosen.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Chosen, a Select Box Enhancer for jQuery and Prototype
Version 2.2.1
Full source at https://github.com/jjj/chosen
Copyright (c) 2011-2022 JJJ
Copyright (c) 2011-2023 JJJ
MIT License, https://github.com/jjj/chosen/blob/master/LICENSE.md
This file is generated by `grunt build`, do not edit it by hand.
*/
Expand Down Expand Up @@ -897,9 +897,9 @@ This file is generated by `grunt build`, do not edit it by hand.
}

get_single_html() {
return `<a class="chosen-single chosen-default">
return `<a class="chosen-single chosen-default" role="button">
<span>${this.default_text}</span>
<div><b></b></div>
<div aria-label="Show options"><b aria-hidden="true"></b></div>
</a>
<div class="chosen-drop">
<div class="chosen-search">
Expand Down Expand Up @@ -1348,6 +1348,7 @@ This file is generated by `grunt build`, do not edit it by hand.
this.container.addClass("chosen-dropup");
}
this.container.addClass("chosen-with-drop");
this.container.find(".chosen-single div").attr("aria-label", "Hide options");
this.results_showing = true;
this.search_field.attr("aria-expanded", true);
this.search_field.trigger("focus");
Expand All @@ -1374,6 +1375,7 @@ This file is generated by `grunt build`, do not edit it by hand.
this.result_clear_highlight();
this.container.removeClass("chosen-with-drop");
this.container.removeClass("chosen-dropup");
this.container.find(".chosen-single div").attr("aria-label", "Show options");
this.form_field_jq.trigger("chosen:hiding_dropdown", {
chosen: this
});
Expand Down
4 changes: 2 additions & 2 deletions docs/chosen.jquery.min.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions docs/chosen.proto.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Chosen, a Select Box Enhancer for jQuery and Prototype
Version 2.2.1
Full source at https://github.com/jjj/chosen
Copyright (c) 2011-2022 JJJ
Copyright (c) 2011-2023 JJJ
MIT License, https://github.com/jjj/chosen/blob/master/LICENSE.md
This file is generated by `grunt build`, do not edit it by hand.
*/
Expand Down Expand Up @@ -897,9 +897,9 @@ This file is generated by `grunt build`, do not edit it by hand.
}

get_single_html() {
return `<a class="chosen-single chosen-default">
return `<a class="chosen-single chosen-default" role="button">
<span>${this.default_text}</span>
<div><b></b></div>
<div aria-label="Show options"><b aria-hidden="true"></b></div>
</a>
<div class="chosen-drop">
<div class="chosen-search">
Expand Down Expand Up @@ -971,7 +971,7 @@ This file is generated by `grunt build`, do not edit it by hand.
set_default_values() {
super.set_default_values();
// HTML Templates
this.single_temp = new Template('<a class="chosen-single chosen-default"><span>#{default}</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" aria-expanded="false" aria-haspopup="true" role="combobox" aria-autocomplete="list" /></div><ul class="chosen-results" role="listbox" aria-busy="true"></ul></div>');
this.single_temp = new Template('<a class="chosen-single chosen-default" role="button"><span>#{default}</span><div aria-label="Show options"><b aria-hidden="true"></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" aria-expanded="false" aria-haspopup="true" role="combobox" aria-autocomplete="list" /></div><ul class="chosen-results" role="listbox" aria-busy="true"></ul></div>');
this.multi_temp = new Template('<ul class="chosen-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" aria-expanded="false" aria-haspopup="true" role="combobox" aria-autocomplete="list" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results" role="listbox" aria-busy="true"></ul></div>');
return this.no_results_temp = new Template('<li class="no-results">' + this.results_none_found + ' "<span>#{terms}</span>"</li>');
}
Expand Down Expand Up @@ -1354,6 +1354,7 @@ This file is generated by `grunt build`, do not edit it by hand.
this.container.addClassName("chosen-dropup");
}
this.container.addClassName("chosen-with-drop");
this.container.find(".chosen-single div").attr("aria-label", "Hide options");
this.results_showing = true;
this.search_field.writeAttribute("aria-expanded", "true");
this.search_field.focus();
Expand All @@ -1380,6 +1381,7 @@ This file is generated by `grunt build`, do not edit it by hand.
this.result_clear_highlight();
this.container.removeClassName("chosen-with-drop");
this.container.removeClassName("chosen-dropup");
this.container.find(".chosen-single div").attr("aria-label", "Show options");
this.form_field.fire("chosen:hiding_dropdown", {
chosen: this
});
Expand Down
4 changes: 2 additions & 2 deletions docs/chosen.proto.min.js

Large diffs are not rendered by default.