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

Issue with large library of icons #22

Closed JeanLucEsser closed 4 years ago

JeanLucEsser commented 4 years ago

Description

When using a large library of icons, either via nested folders or in a single folder, loading an edit page with the icon picker field takes forever and fails. I guess it tries to index all icons. I tried to set maxIconsShown to 0 but it doesn't change anything.

Is there a way to handle a library with 10k+ icons. I'm using the full Streamline 3.0 library.

Bonus question: Would it be possible to use the title and desc tags in svg to search for the icons? Right now it looks like it only uses the filename as a search term.

Additional info

engram-design commented 4 years ago

Greatly improved in 1.1.0. We've implemented full caching of icon sets, and lazy-loading into the picker field.

I've tested with the pro version of Streamline (40k icons), and while it does take a few seconds to load, better than nothing. I probably wouldn't encourage the use of all of these on a production environment!

And you'll also want to use the maxIconsShown config setting. This helps to improve performance by not rendering every icon. They're all fully searchable.

Which brings me to your next point, I'm looking at the SVGs and can't see desc tags?

See also docs

JeanLucEsser commented 4 years ago

@engram-design Thanks that is way way better, caching makes a world of difference.

But I now have an issue with the property maxIconsShown that used to not impact searching and does now. I can see why you would want to limit searching on large sets of icons, for performance, but it would be nice not to tie it to the same property which limits the default max icons shown.

About my other point, I made a wrong assumption that IconJar could export tags as inline SVG's desc tags. Confused it with the ability of naming files from tags. Still I think that is a missed opportunity for icon sets in general but it would be a useless feature to support as no one uses it. Sorry about that confusion.

engram-design commented 4 years ago

@JeanLucEsser So just looking at this again - maxIconsShown shouldn't actually be limiting any results anymore, due to how I've refactored things. I'm working on fixing this, but are you seeing something different? Are you unable to search for items after a certain point?

And agreed on the inline SVG description tags - I've actually yet to come across an icon set that makes use of these.

EDIT: My mistake, maxIconsShown actually does work (I was working on two different installs), but it works as expected. For instance, I can set this to 10, and it'll only ever show 10 icons. I can search for icons starting with "a" through "z", so there shouldn't be anything limiting the actual search?

JeanLucEsser commented 4 years ago

@engram-design Ok, so just so I understand:

Per the doc: maxIconsShown - Set the maximum number of icons shown to pick from in the icon selection pane. This will not effect searching.

What I understand and expect as behavior is that if set to 10, it shows 10 icons by default, but when searching, it does not limit to 10 (ie building would return 19 results).

What I was hoping to use it for is set it to 0 so no icons are shown by default, but searching remains unaffected.

Do we agree on this?

engram-design commented 4 years ago

That's probably slightly different behaviour. This controls the maximum number of icons shown in the dropdown, when searching. So setting this to 0 means the field is essentially useless, because 0 icons will be shown in the dropdown to pick!

This setting is much more for when you've got massive icon packs, and the DOM would really choke when trying to render those nodes for thousands of items. Instead, its best to set this to a reasonable value for how many to show/render, but searching remains unaffected.

I think what you'd be after is an initialIconsShown setting, which I can add as a feature request