microsoft-search / pnp-modern-search

Home of PnP Modern Search solutions, helping you move from classic to modern SharePoint and beyond
https://microsoft-search.github.io/pnp-modern-search
Other
387 stars 340 forks source link

Error "Cannot read properties of undefined" on first load #3823

Closed JungLSEDV closed 2 months ago

JungLSEDV commented 3 months ago

Version used 4.12.2

Describe the bug When opening the Page for the first time the PnP Search-Results Webpart will throw an Error

To Reproduce Detailed steps to reproduce the behavior:

  1. Clear Cache/Open Browser with Incognito mode
  2. Go to Sharepoint Website with a PnP Search-Results Webpart present
  3. The Error should pop up

Expected behavior An Empty Search-Results Webpart should be displayed/not be displayed since nothing is input into the Search Box Webpart

Screenshots Chrome: image

Firefox: image

Desktop (please complete the following information): Tested in Chrome (126.0.6478.115 64-Bit) and Firefox (127.0.1 64-Bit)

Additional context We use the Search Results as a Person-Search to find Coworkers via our Intranet page (Set up similar to the "useful people search" but without the Filters Webpart) We had the same issue some time ago when we first set up our page with version 4.10.2 But similar to Issue #3700 it was fixed with 4.11.0 I have the strange feeling it came back with 4.12.* but i just made aware of it today so i havent had the time to try to revert to 4.11.

rdel49 commented 3 months ago

I was noticing this issue too last week; it appears to be linked to the Microsoft Graph Toolkit toggle for Sharepoint Search with People layout.

I had "Use Microsoft Graph Toolkit" checked. When checked, any Ctrl+F5 refresh of the page would result in an error similar to below: image

When I unchecked "Use Microsoft Graph Toolkit" I do not see this error when doing a Ctrl + F5 refresh.

Note: In our case, our page for this search by default will pass in the query "*" and try to fetch all people upon initial load (~15-20 at the moment)

JungLSEDV commented 3 months ago

Since my Issue we reverted back to 4.11.1. This Version does NOT have this issue.

After @rdel49 's comment i checked and we also have the "Use Microsoft Graph Toolkit" toggle enabled I can also confirm without the Toggle we do not get the Error, but we dont get search results either, but that may be our Query Search-Query: "{searchTerms}* WorkEMail:workdomain -.az" (Search everyone having a workmail and not having .az as a mailsuffix) Standard-Value: "XXX" (Should Display as empty since noone should have that Name)

mobun commented 2 months ago

@rdel49 & @JungLSEDV quick question. I came across the issue because the error is only displayed in the browser console (Use Microsoft Graph Toolkit was already deactivated). Can you also reproduce this?

kasperbolarsen commented 2 months ago

Since my Issue we reverted back to 4.11.1. This Version does NOT have this issue.

After @rdel49 's comment i checked and we also have the "Use Microsoft Graph Toolkit" toggle enabled I can also confirm without the Toggle we do not get the Error, but we dont get search results either, but that may be our Query Search-Query: "{searchTerms}* WorkEMail:workdomain -.az" (Search everyone having a workmail and not having .az as a mailsuffix) Standard-Value: "XXX" (Should Display as empty since noone should have that Name)

I would think that you query should be: ({searchTerms}*) -WorkEMail:_workdomain_.az KQL doesn't support "ends with"

JungLSEDV commented 2 months ago

@mobun i can confirm, that with "Use Microsoft Graph Toolkit" disabled, there is still an error Message on the Browser Console image

@kasperbolarsen i have now modified my Query to this ({searchTerms}*) //Searchfilter Field (WorkEMail:workdomain.de) //WorkEMail contains our workdomain (excludes all external partners in our AD) (-WorkEMail:.az*) //exclude addresses contiaining .az (.az ist our suffix for apprentices) (-WorkEMail:auszubildende*) //exclude group-users for apprentices (-WorkEMail:admin*) //exclude users with admin in their Mail address

mobun commented 2 months ago

I can no longer reproduce the error. Maybe the whole thing has been fixed by MSFT through an update in SharePoint? Since I have not actively made any changes, I assume that this is the case.