Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with the RegExp replacement of the searchTerm #37

Closed
Katulka opened this issue Apr 10, 2020 · 6 comments
Closed

Issue with the RegExp replacement of the searchTerm #37

Katulka opened this issue Apr 10, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@Katulka
Copy link

Katulka commented Apr 10, 2020

Only in Production, having an issue with this line:

result.titleFormatted = result.title
? result.title.replace(regex, '' + this.searchTerm + '')
: result.title;

this.searchTerm = "he"
result.title = "obfuscated community name he"

Testing:

  • Only happens on the first page load
  • Get failure on that line after user types "he" in the lookup
  • Error is blank in the "catch" of the js
  • Type he again and it works fine

Cannot replicate this in sandbox.

For now I am getting rid of RegExp and doing this:

result.title.replace(this.searchTerm, '' + this.searchTerm + '')

@pozil
Copy link
Owner

pozil commented Apr 10, 2020

Hi @Katulka, if I get this right, you only have an issue on the JS side in production, right?
Could there be something special in your prod data?

Can you check that by logging search results in the dev console just before applying the regex like this:

this.searchResults = results.map((result) => {
   console.log(JSON.stringify(result, null, 2));
   ...

@Katulka
Copy link
Author

Katulka commented Apr 10, 2020

Hi @pozil thanks so much. Hope you are well.

FYI - this is helping a community screen visitors for Covid-19 reasons.. so it's important right now. Thanks for helping.

Here you go.. I am also finding it's not the RegExp but simply the assignment of result.titleFormatted

{
"icon": "utility:world",
"id": "a0C0B00000u6666UAA",
"sObjectType": "Community",
"subtitle": "Community • obfuscated community name",
"title": "obfuscated community name"
}
modules/c/lookup.js:4 {
"icon": "utility:world",
"id": "a0C0B00000u6666UA2",
"sObjectType": "Community",
"subtitle": "Community • obfuscated community name",
"title": "obfuscated community name"
}
modules/c/lookup.js:4 {
"icon": "utility:world",
"id": "a0C0B00000u6666UA2",
"sObjectType": "Community",
"subtitle": "Community • obfuscated community name",
"title": "obfuscated community name"
}
modules/c/lookup.js:4 {
"icon": "utility:world",
"id": "a0CU00000006666MAI",
"sObjectType": "Community",
"subtitle": "Community • obfuscated community name",
"title": "obfuscated community name"
}
modules/c/lookup.js:4 {
"icon": "utility:world",
"id": "a0C0B00000u6666UAU",
"sObjectType": "Community",
"subtitle": "Community • obfuscated community name",
"title": "obfuscated community name"
}
modules/c/lookup.js:4 {
"icon": "utility:world",
"id": "a0CU000000b6666MA4",
"sObjectType": "Community",
"subtitle": "Community • obfuscated community name",
"title": "obfuscated community name"
}
modules/c/lookup.js:4 {
"icon": "utility:world",
"id": "a0CU000000b6666MA4",
"sObjectType": "Community",
"subtitle": "Community • obfuscated community name",
"title": "obfuscated community name"
}
modules/c/lookup.js:4 {
"icon": "utility:world",
"id": "a0C0B00000s6666UAS",
"sObjectType": "Community",
"subtitle": "Community • obfuscated community name",
"title": "obfuscated community name"
}

@Katulka
Copy link
Author

Katulka commented Apr 10, 2020

This just fixed it, I think it's a scope/lwc restriction.. cut ties with the reference and it's working

 setSearchResults(results) {
        // Reset the spinner
        this.loading = false;

        // cut ties with the reference, locker service in prod is unhappy looping through the results by ref and modifying them

        let resultsLocal = JSON.parse(JSON.stringify(results));

        this.searchResults = resultsLocal.map((result) => {

@pozil pozil added the bug Something isn't working label Apr 10, 2020
@Katulka
Copy link
Author

Katulka commented Apr 10, 2020

image

Working version, showing results on first attempt. This is a great lookup thanks!

@pozil
Copy link
Owner

pozil commented Apr 10, 2020

Thanks for finding the issue so quickly @Katulka.
I've released v1.3.2 with the fix.

Good luck with your project and stay safe.

@pozil pozil closed this as completed Apr 10, 2020
@Katulka
Copy link
Author

Katulka commented Apr 10, 2020

You are welcome and thanks @pozil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants