Pnp-modern-search: Preview pane showing error text for some results in Simple List layout

Created on 20 May 2020  路  6Comments  路  Source: microsoft-search/pnp-modern-search

Version used
3.12.1

Describe the bug
Preview pane showing below error text for results in Simple List layout where there are Folder result items.

{"error":{"code":"itemNotFound","message":"The specified thumbnail set does not exist."}}

MicrosoftTeams-image

To Reproduce
Steps to reproduce the behavior:

  1. Add Search box, Search Results web-parts to the page
  2. Configure the Search Results to show the results in Simple List layout
  3. Enter some search term and press enter
  4. In results look for the results for Folder names
  5. Try to click on the preview image to open the preview pane.
  6. See the error

Expected behavior
It should show some default image or show text as - No preview available

Desktop (please complete the following information):

  • Chrome

All 6 comments

Thanks @malcom1120 .

Unfortunately I don't yet have the development environment setup for SPFx projects. Can you please provide the .sppkg file with this fix?

Thanks in advance.

@AmitTyagi1 As a workaround until my bug fix gets merged into the package and released.

  • Add IsDocument manage property to the returned properites
  • Customize the default simple-list layout by changing {{#if (getPreviewSrc item)}} with {{#eq IsDocument 'true'}}

Sure, I am going to try it right away. Thanks a lot.

@malcom1120 sorry it didn't worked for me. Do we have to make any changes in the {{else}} block too ?

Attached is the full block for the preview container. The preview container shouldn't even show if it is not a document. I noticed yesterday that it was showing for Pages, Containers and ListItems. My bug fix, fixes all of those. This is the main part that corrects it. It makes it behave like the out of the box result item.

<div class="template_previewContainer ms-hiddenSm"> {{#eq IsDocument 'true'}} {{#isnt FileType 'aspx'}} <div class="doc-container"> <div class="img-container"> <img class="document-preview-item img-preview" width="120" loading="lazy" src="{{getPreviewSrc item}}" data-src="{{getPreviewSrc item}}" data-url="{{#eq FileType 'pdf'}}{{#contains Path '-my.sharepoint'}}{{{ServerRedirectedEmbedURL}}}{{else}}{{{Path}}}{{/contains}}{{else}}{{{ServerRedirectedEmbedURL}}}{{/eq}}" onerror="this.onerror=null;this.src='{{@root.utils.defaultImage}}';"/> <div class="hover"> <div><i class="ms-Icon ms-Icon--Preview" aria-hidden="true"></i></div> </div> </div> </div> {{/isnt}} {{/eq}} </div>

Perfect @malcom1120 . It worked for me.

Was this page helpful?
0 / 5 - 0 ratings