From 7e938b796f9304a4b77f021136d88826182fe6a9 Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Wed, 13 Dec 2017 14:30:10 -0600 Subject: [PATCH] Filter: Select exact matches ignore "and" and "or" keywords. Fixes #1486 --- docs/example-widget-filter-custom-search.html | 4 +++- docs/index.html | 2 +- js/widgets/widget-filter.js | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/example-widget-filter-custom-search.html b/docs/example-widget-filter-custom-search.html index 77f91630..aff556ec 100644 --- a/docs/example-widget-filter-custom-search.html +++ b/docs/example-widget-filter-custom-search.html @@ -100,6 +100,7 @@ $(function() {

Notes


diff --git a/docs/index.html b/docs/index.html index 90bfa1d3..064c2f00 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2903,7 +2903,7 @@ filter_cellFilter : [ '', 'hidden', '', 'hidden' ] Filter widget: Customize the filter widget by adding a select dropdown with content, custom options or custom filter functions (v2.3.6; v2.17.0).

- In v2.22.0, a data parameter was added to that long list of parameters.

+ In v2.22.0, a data parameter was added to that long list of parameters.

*WARNING* In a future update, the filter function parameters will be cleaned up and changed as follows!
filter_functions : {
   // function(e, n, f, i, $r, c, data) {} <- current parameters
diff --git a/js/widgets/widget-filter.js b/js/widgets/widget-filter.js
index 5a5b7607..2233eee2 100644
--- a/js/widgets/widget-filter.js
+++ b/js/widgets/widget-filter.js
@@ -1115,6 +1115,7 @@
 				if ( $.inArray( ffxn, vars.excludeMatch ) < 0 && matches === null ) {
 					matches = tsf.types[ffxn]( c, data, vars );
 					if ( matches !== null ) {
+						data.matchedOn = ffxn;
 						filterMatched = matches;
 					}
 				}
@@ -1162,6 +1163,7 @@
 					tsf.multipleColumns( c, wo.filter_$anyMatch ) :
 					[];
 			data.$cells = data.$row.children();
+			data.matchedOn = null;
 			if ( data.anyMatchFlag && columnIndex.length > 1 || ( data.anyMatchFilter && !hasAnyMatchInput ) ) {
 				data.anyMatch = true;
 				data.isMatch = true;
@@ -1263,7 +1265,9 @@
 						// cycle through the different filters
 						// filters return a boolean or null if nothing matches
 						filterMatched = tsf.processTypes( c, data, vars );
-						if ( filterMatched !== null ) {
+						// select with exact match; ignore "and" or "or" within the text; fixes #1486
+						txt = fxn === true && (data.matchedOn === 'and' || data.matchedOn === 'or');
+						if ( filterMatched !== null && !txt) {
 							result = filterMatched;
 						// Look for match, and add child row data for matching
 						} else {