mattmilburn / strapi-plugin-preview-button

A plugin for Strapi CMS that adds a preview button and live view button to the content manager edit view.
MIT License
100 stars 35 forks source link

"Open live view" button not visible if field have "%" char. #124

Open Miro0 opened 10 months ago

Miro0 commented 10 months ago

I noticed following issue - tested with current version 2.2.1.

Minimum steps to reproduce:

  1. Defined minimum content type:
    {
    "kind": "collectionType",
    "collectionName": "tests",
    "info": {
    "singularName": "test",
    "pluralName": "tests",
    "displayName": "Test",
    "description": ""
    },
    "attributes": {
    "Test": {
      "type": "string"
    }
    }
    }
  2. Added plugin config:
    'preview-button': {
    config: {
      contentTypes: [
        {
          uid: 'api::test.test',
          published: {
            url: `http://localhost:3000/test/{id}`,
            openTarget: '_blank',
          },
        }
      ],
    },
    },
  3. Content:
    • If there's no % char in field - Open live view exists: image
    • If there's % char in field - Open live view do not exists: image

There is also additional error in browser console:

main.c2325b99.js:2185 Uncaught (in promise) URIError: URI malformed
    at decodeURIComponent (<anonymous>)
    at main.c2325b99.js:2185:1707
    at Array.reduce (<anonymous>)
    at P (main.c2325b99.js:2185:1636)
    at z (main.c2325b99.js:2185:1952)
    at main.c2325b99.js:2185:3391

thrown in main.c2325b99.js:2185 image

mattmilburn commented 9 months ago

Hi @Miro0 This was actually fixed in 2.2.1 🤔 Have you tried removing yarn.lock or node_modules and reinstalling with yarn? That encodeURIcomponent(decodeURIComponent(value)) code was definitely replaced in the latest version.