Set focus on first item in drop down (textbox, link, whatever it may be)

Set focus on first item in the drop down for keyboard users, so they can quickly tab to the link/item of their choosing.
https://meta.discourse.org/t/keyboard-shortcuts-wish-list/15952
This commit is contained in:
cpradio 2014-08-28 11:33:45 -04:00
parent fc71662a13
commit a40b08f210

View file

@ -58,7 +58,7 @@ export default Discourse.View.extend({
// fade it fast // fade it fast
$dropdown.fadeIn('fast'); $dropdown.fadeIn('fast');
// autofocus any text input field // autofocus any text input field
$dropdown.find('input[type=text]').focus().select(); $dropdown.find('input[type=text],a:first').focus().select();
$html.on('click.d-dropdown', function(e) { $html.on('click.d-dropdown', function(e) {
return $(e.target).closest('.d-dropdown').length > 0 ? true : hideDropdown.apply(self); return $(e.target).closest('.d-dropdown').length > 0 ? true : hideDropdown.apply(self);