Hi I migrated today to v.1.1.0 and adapted all params. I got problems with the text-selection. When I typed in one letter in the ng-select-component I got this error
TypeError: value.match is not a function
at HighlightPipe.transform (select-pipes.js:15)
It seems that the function receives a sanitized value and not a pure value. So by adding one line to check the value if it is sanitized or not solves the problem.
HighlightPipe.prototype.transform = function (_value, args) {
//this line fixes the problem
var value = _value.changingThisBreaksApplicationSecurity ? value.changingThisBreaksApplicationSecurity:_value;
if (args.length < 1) {
return value;
}
var query = args[0];
if (query) {
var tagRE = new RegExp('<[^<>]*>', 'ig');
// get ist of tags
var tagList = value.match(tagRE);
I hope you can fix it soon. It blocks our migration to 1.1.0.
Same as #437 #438
As this major bug is present in the only version supporting Angular2, fixing it soon would be really appreciated.
+1
To follow up with @GreenToast's recommendation, if anyone is looking for a hotfix, you can drop this into your main.ts file:
import {escapeRegexp} from 'ng2-select/components/select/common';
import {HighlightPipe} from 'ng2-select/components/select/select-pipes';
HighlightPipe.prototype.transform = (value: any, args: any[]) => {
if (args.length < 1) {
return value;
}
let query = args[0];
if ( query ) {
value = value.changingThisBreaksApplicationSecurity || value;
let tagRE = new RegExp('<[^<>]*>', 'ig');
// get ist of tags
let tagList = value.match( tagRE );
// Replace tags with token
let tmpValue = value.replace( tagRE, '$!$');
// Replace search words
value = tmpValue.replace(
new RegExp(escapeRegexp(query), 'gi'),
'<strong>$&</strong>'
);
// Reinsert HTML
for (let i = 0; value.indexOf('$!$') > -1; i++) {
value = value.replace('$!$', tagList[i]);
}
}
return value;
};
+1 @Scipionh
@moodyroto Nice workaround. It worked for me.
@valorkin Hope this issue might be addressed in the package also sometime later.
Are you getting HighlightPipe.prototype.transform = (value: any, args: any[]) => { args parameter as an array? For me it was a string and so it ended up highlighting only the first character. I created a PR (#454) that fixed this issue in here.
Most helpful comment
To follow up with @GreenToast's recommendation, if anyone is looking for a hotfix, you can drop this into your
main.tsfile: