Browse Source

Add abiility to autofocus in menu search

pull/3763/merge
Jack Lukic 8 years ago
parent
commit
e3ad10ffe4
2 changed files with 10 additions and 3 deletions
  1. 1
      RELEASE-NOTES.md
  2. 12
      src/definitions/modules/dropdown.js

1
RELEASE-NOTES.md

@ -82,6 +82,7 @@
- **Site** - Added colored box shadow defaults. `ui message` now includes individual colored border shadows based on new site defaults.
- **Dropdown** - Adds new setting `minCharacters` which sets the minimum number of characters required to start filtering results #3886
- **Dropdown** - Added `1px` offset for current text so that the text position cursor does not overlap first pixel of text.
- **Dropdown** - Dropdown will now automatically focus on `search` inside of a menu after it is opened.
- **Dropdown** - Added new convenience method `restore placeholder text`
- **Rating** - Added new setting `fireOnInit` for rating, which defaults to `false`. When set to true `onRate` will fire when rating is initialized #3712
- **Site** `@px` and `@relativepx` i.e. `@relative12px` which can be used to return EM value of pixels are now extended to `@relative40px`

12
src/definitions/modules/dropdown.js

@ -460,6 +460,9 @@ $.fn.dropdown = function(parameters) {
if( module.can.click() ) {
module.bind.intent();
}
if(module.has.menuSearch()) {
module.focusSearch();
}
module.set.visible();
callback.call(element);
});
@ -827,11 +830,11 @@ $.fn.dropdown = function(parameters) {
},
focusSearch: function(skipHandler) {
if( module.is.search() && !module.is.focusedOnSearch() ) {
if( module.has.search() && !module.is.focusedOnSearch() ) {
if(skipHandler) {
$module.off('focus' + eventNamespace, selector.search);
$search.focus();
$module.on('focus' + eventNamespace, selector.search, module.event.search.focus)
$module.on('focus' + eventNamespace, selector.search, module.event.search.focus);
}
else {
$search.focus();
@ -2833,6 +2836,9 @@ $.fn.dropdown = function(parameters) {
},
has: {
menuSearch: function() {
return (module.has.search() && $search.closest($menu).length > 0);
},
search: function() {
return ($search.length > 0);
},
@ -3546,7 +3552,7 @@ $.fn.dropdown.settings = {
menu : '.menu',
message : '.message',
menuIcon : '.dropdown.icon',
search : 'input.search, .menu > .search > input',
search : 'input.search, .menu > .search > input, .menu input.search',
sizer : '> input.sizer',
text : '> .text:not(.icon)',
unselectable : '.disabled, .filtered'

Loading…
Cancel
Save