pnp / sp-dev-fx-controls-react

Reusable React controls for SPFx solutions
https://pnp.github.io/sp-dev-fx-controls-react/
MIT License
383 stars 380 forks source link

SitePicker control do not show all sites? #1026

Closed spverma03 closed 2 years ago

spverma03 commented 2 years ago

Category

[ ] Enhancement

[x] Bug

[x] Question

We are observing that not all sites are fetched by PnP Site Picker Control. It seems 500 items are getting fetched on load of control. There are more sites in the tenant. When user types, the intended result is not shown as it was not fetched initially. New call for data do not trigged as we type the search-keyword.

This is certainly a bug.

Reference: https://pnp.github.io/sp-dev-fx-controls-react/controls/SitePicker/

<SitePicker context={this.props.context} label={'Select sites'} mode={'site'} allowSearch={true} multiSelect={false} onChange={(sites) => { console.log(sites); }} placeholder={'Select sites'} searchPlaceholder={'Filter sites'} />

ghost commented 2 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

AJIXuMuK commented 2 years ago

Hi @spverma03 - thank you for reporting this one. I don't think I have any environment to test with more than 500 sites, so I will need your help here.

Could you please check how many _api/search/query requests you see in the Network when opening the site picker? Could you also send me screenshots or results for PrimaryResults.RelevantResults.TotalRows from these request(s)?

Thanks!

spverma03 commented 2 years ago

Hi @AJIXuMuK - Thank you for your prompt reply. I cannot share exact data due to data protection policies of my client. Following are details that maybe useful for you to triage:

API: Tenant URL/sites/mysite/_api/search/query?querytext=%27contentclass:STS_Site%20Path:*%27&selectproperties=%27SiteId,SiteID,WebId,DepartmentId,Title,Path%27&rowlimit=500&startrow=0

Query String Parameters: querytext: 'contentclass:STS_Site Path:*tenant url' selectproperties: 'SiteId,SiteID,WebId,DepartmentId,Title,Path' rowlimit: 500 startrow: 0

image

spverma03 commented 2 years ago

@AJIXuMuK ,

I tried modifying the definition to increase the row limit by changing code inside node-modules but it didn't worked. The SitePicker kept on loading. I could see continuous search query being made in the network tab of browser.

As I'm looking for a quick solution currently, may you think of some work-arounds for time being until the resolution is pushed to repo:

  1. Can we add more filters to the control so that we can specify site type? The mode 'site/hub/web' is not sufficient. For example, in my case, I just want to get all Communication sites only.

Suggest if I can modify query in node-modules in current implementation as a quick-fix, if possible.

  1. Can we increase row-limit somehow? Is there any threshold/limit etc.

I have also observed that this issue is more prominent when I open a previously populated SitePicker instead of adding a new one. I see some more sites missing in edit mode.

AJIXuMuK commented 2 years ago

Hi @spverma03,

  1. You can try to make the change in node_modules. And it would be a good enhancement in future.
  2. the maximum row limit for search query is 500. That's why there is a loop in the code to do multiple requests if needed.

I'll try to repro it.

AJIXuMuK commented 2 years ago

@spverma03 I decreased rowLimit locally to 5 to repro the issue. But it behaves correctly.

When you're saying you see continuous search requests in network tab - what is the startrow in these requests? Is it changing?

In my case I see like that:

Screen Shot 2021-10-03 at 11 45 00 AM
spverma03 commented 2 years ago

@AJIXuMuK , I further investigated this it seems to be something related to search excluding some sites as duplicates. Most of the sites in our tenant are created using a template and some has similar kind of data.

I tried testing this out using search query tool and figured out that when I add parameter trimduplicates=false, all my sites come up.

The problem is, if I try to add this parameter in SPSitesServices.js file, the site picker goes into endless loop. I can see network tab making continuous search queries. In fact any change made directly to this file results in endless search queries being fired in loop. I may be breaking something by manipulating this file directly.

Do you have any suggestions? Thank you in advance

AJIXuMuK commented 2 years ago

@spverma03 - I have changed the query to be POST and added support for trimDuplicates and additionalQuery. You can try these new features in beta version and check if it works.

spverma03 commented 2 years ago

@AJIXuMuK - Thank you for your prompt assistance. I tried the beta version and it is working for me. Eagerly waiting for the stable release (3.4.0). We are not allowed to use beta versions in client/production.

Do you have any expected timeline for version 3.4.0 roll-out?

Again, thank you promptly addressing this issue. It will help the community.

AJIXuMuK commented 2 years ago

@spverma03 - we're planning to release a new version in the next couple of days

spverma03 commented 2 years ago

@AJIXuMuK - Thank you for the update.

Meanwhile I observed similar issue in @pnp/spfx-property-controls where the OOB shows 5 search results by default and has option of Show More. In case of PropertyFieldSitePicker control there are only 5 search results (Can we make this configurable at least or have a show more CTA). Unlike OOB control, we cannot search by URL (Good to have search by URL feature). Due to this, the control sometimes do not show the searched site in the options.

For example, in my case there are many sites having keyword 'Home' in the site title such as various department home sites, teams home sites etc. There is also one landing site whose title is just 'Home'. When I search for keyword 'Home' I get random 3 search results but I do not find any option to search for the landing home site. In OOB webpart I can see the 'Home' site in default 5 search results, also I can search for the site using exact URL.

Can we also implement remove duplicate search query changes in this control as well?

Any suggestions?