verbb / icon-picker

A Craft CMS field to select SVG or font icons from a folder for use in your content.
Other
17 stars 8 forks source link

Craft 4 upgrade loose Icon values #60

Closed davola closed 1 year ago

davola commented 1 year ago

Describe the bug

After migrating Craft from v3.5 to v4.0.3 the icon values stored on the entries are lost.

Steps to reproduce

  1. Update craft 3.5 to craft 4 along with icon-picker from 1.1.14 to 2.0.5
  2. Visit any entry that had an icon value stored
  3. the icon field will be empty (the value is no longer persisted)
  4. Also executing a graphql query the field value returns as null
  5. Note: Editing the empty field and choosing a new icon works and persists properly

The images below illustrate the effect after the upgrade descrived above

  1. (the icon fields are shown empty) image

  2. (the icon values are shown as null on a graphql query image

Craft CMS version

4.0.3

Plugin version

2.0.5

Multi-site?

yes

Additional context

I had to create a default iconset in order for the icons to shown after the upgrade.

engram-design commented 1 year ago

The migration should look at any icon folders or files you have in your Icon Path folder, and create icon sets for those automatically.

Can you let me know what sort of icons you had before the update? Was it SVGs, Sprites or Web fonts? If just SVGs, where they in a folder, or in the root of your Icons Path folder?

davola commented 1 year ago

Hey @engram-design , thanks for the reply.

For your reference, this is my icon-pciker.php file

# config/icon-picker.php
<?php

return [
    '*' => [
        'iconSetsPath' => '@webroot/icons/',
        'iconSetsUrl' => '@web/icons/',
        'maxIconsShown' => 100,
        'redactorFieldHandle' => '',
    ]
];

My icons are on a custom web/icons directory (relative to craft root dir), and they are all SVG files.

If I don't crete the iconset manually, the icons are not being recognized, as follows

Thanks!

corneliusio commented 1 year ago

Calling out that I just ran into this issue NOT updating from Craft 3 to 4 (already running 4), but updating from Icon Picker 2.0.0-beta.5 to 2.0.5.

The original path to our icons on the project was updated to /icon-picker and none of our icons in the existing directory (all separate SVG files grouped by style in subdirectories) were carried over to any set. Additionally, I was forced to create separate sets for each subdirectory/style which isn't necessarily an issue but is a bit of a bummer that files in subdirectories are no longer detected.

davola commented 1 year ago

I want to add that I have no problem creating the sets manually, indeed I did on an attempt to fix the issue, but although creating them manually allows the icons to work again, still all the previous stored values are lost in the update.

CreateSean commented 1 year ago

Calling out that I just ran into this issue NOT updating from Craft 3 to 4 (already running 4), but updating from Icon Picker 2.0.0-beta.5 to 2.0.5.

The original path to our icons on the project was updated to /icon-picker and none of our icons in the existing directory (all separate SVG files grouped by style in subdirectories) were carried over to any set. Additionally, I was forced to create separate sets for each subdirectory/style which isn't necessarily an issue but is a bit of a bummer that files in subdirectories are no longer detected.

I had to rollback an update from the beta because all my icons disappeared from the control panel.

updating Craft to latest but will lock icon-picker on the beta-4 until a fix is ready or instructions for a working update.

engram-design commented 1 year ago

Thanks for the feedback, looks like this is related to root-only SVG icons not getting their icon set created, or when the field settings have "All" selected.

Should be fixed in 2.0.6, and this will also fix any already-migrated installs in case you continued on with development after the upgrade, rather than rolling back.

You will likely want to rename the default [root] icon set that now gets created. This was automatically assumed in previous versions, but now as you need to specifically state which folders you want to look at (even the root folder) this icon set must be created. Feel free to rename it to something more meaningful!