Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Case-insensitive matching in autoComplete #388

Closed
Shamilik opened this issue Mar 9, 2015 · 4 comments
Closed

Case-insensitive matching in autoComplete #388

Shamilik opened this issue Mar 9, 2015 · 4 comments

Comments

@Shamilik
Copy link

Shamilik commented Mar 9, 2015

Is there any way to make matching in autoComplete case-insensitive?

@mbenford
Copy link
Owner

What exactly do you mean by "matching"?

@Shamilik
Copy link
Author

image
image

@goull
Copy link

goull commented Mar 23, 2015

Up
I replaced the function with a decorator

app.config(function($provide) {
    $provide.decorator('tiUtil', function($delegate) {
$delegate.safeHighlight = function(str, value) {
if (!value) {
                return str;
            }

function escapeRegexChars(str) {
                return str.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
            }

 var expression = new RegExp('&[^;]+;|' + escapeRegexChars(value), 'gi');
            return str.replace(expression, function(match) {
                **changed to case insensitive match**
                **return match.toLowerCase() === value.toLowerCase() ? '<em>' + match + '</em>' : match;**
            });
        };

 return $delegate;
    });
});

@goull
Copy link

goull commented Mar 23, 2015

Could be implemented with a property on autocomplete tag (ex. <auto-complete highlight-ig="true"...)

@mbenford mbenford added this to the 2.3.0 milestone Mar 23, 2015
Bessonov pushed a commit to Bessonov/ngTagsInput.ie8 that referenced this issue May 3, 2015
Fix the safeHighlight function so it works in a case insensitive way and
correctly highlights matches regardless of both the match case and the
query case.

Closes mbenford#388
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants