Browse Source

Fix #1601 Search Selection RegExp Escapes Search Values

pull/1627/head
jlukic 10 years ago
parent
commit
70d040f920
2 changed files with 14 additions and 5 deletions
  1. 3
      RELEASE-NOTES.md
  2. 16
      src/definitions/modules/dropdown.js

3
RELEASE-NOTES.md

@ -4,13 +4,14 @@
**Major Changes**
- **Project** - Right-to-left (RTL) support added. New gulp tasks for RTL file generation. Docs do not yet support RTL.*Thanks @MohammadYounes!*.
- **Project** - Express/Custom install now let you specify the outputted file permissions and RTL use
- **Project** - Install now let you specify the outputted file permissions and RTL use (express/custom install)
**Enhancements**
- **Grid** - Grid's ``equal height row` now uses a combination of `flexbox` and ``display: table-cell`` for older browsers
- **Site** - Form input highlighting color added (helps differentiate form colors with autocompleted fields). Default text highlighting color moved from highlighter yellow to a mellow blue.
- **Dropdown** - Dropdown can now be disabled by adding ``disabled` class without requiring `destroy`. **Thanks Psyton**
- **Dropdown** - Search dropdown input can now have backgrounds. Fixes issues with autocompleted search dropdowns which have forced yellow "autocompleted" bg.
- **Dropdown** - Fix issue with search selection not correctly matching when values are not strings
- **Sidebar** - Having a sidebar visible on page load is now much simpler. You can include ``ui visible sidebar`` on page load to have a sidebar element appear on page load. To close call `$('.ui.sidebar').sidebar('hide')`
- **Progress* - Progress bars can now display percent or amount left using `{value}` in text templates
- **Dropdown** - New `upward dropdown` variation, which opens its menu upward. Default animation now uses ``settings.transition = 'auto'` and determines direction of animation based on menu direction

16
src/definitions/modules/dropdown.js

@ -364,8 +364,9 @@ $.fn.dropdown = function(parameters) {
filter: function(searchTerm) {
var
$results = $(),
exactRegExp = new RegExp('^' + searchTerm, 'igm'),
fullTextRegExp = new RegExp(searchTerm, 'ig'),
escapedTerm = module.escape.regExp(searchTerm),
exactRegExp = new RegExp('^' + escapedTerm, 'igm'),
fullTextRegExp = new RegExp(escapedTerm, 'ig'),
allItemsFiltered
;
module.verbose('Searching for matching values');
@ -373,8 +374,8 @@ $.fn.dropdown = function(parameters) {
.each(function(){
var
$choice = $(this),
text = module.get.choiceText($choice, false),
value = module.get.choiceValue($choice, text)
text = String(module.get.choiceText($choice, false)),
value = String(module.get.choiceValue($choice, text))
;
if( text.match(exactRegExp) || value.match(exactRegExp) ) {
$results = $results.add($choice);
@ -1341,6 +1342,13 @@ $.fn.dropdown = function(parameters) {
}
},
escape: {
regExp: function(text) {
text = String(text);
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
},
setting: function(name, value) {
module.debug('Changing setting', name, value);
if( $.isPlainObject(name) ) {

Loading…
Cancel
Save