timmyomahony / craft-matrix-field-preview

Configure a screenshot preview for all your matrix field blocks, giving your clients a better publishing experience.
https://plugins.craftcms.com/matrix-field-preview
Other
16 stars 4 forks source link

Neo Field Previews ordering is not being rendered correctly. #93

Closed robinsm closed 2 years ago

robinsm commented 2 years ago

The following issue is in relation to Neo blocks but may also apply to Matrix blocks.

When changing the order of blocks/previews in the Configure Neo Field Previews view, the ordering of the blocks/previews is not rendered correctly when leaving and then subsequently returning to the same view.

The underlying data held in the table in the sortOrder column does appear to be correct but is just being ignored.

This same issue also affects the content authoring when viewing the overlay modal that displays the Neo content blocks. The ordering isn't adhered to.

Let me know if you'd like any further clarification.

robinsm commented 2 years ago

Happens when we have more than 10 (Neo) blocks and I tested a fix here.

https://github.com/weareferal/craft-matrix-field-preview/blob/bc312b2f078ee0d9302c52333e5f02f3049ea00c/src/services/BaseBlockTypeConfigService.php#L124

return strnatcmp($a->sortOrder, $b->sortOrder);

timmyomahony commented 2 years ago

Thanks for the report @robinsm , I'm not sure why I was using strcmp in the first place, as the sortOrder column is a smallint. I've updated it to use a proper comparison function in version 4.0.3 which should fix the problem.

https://github.com/weareferal/craft-matrix-field-preview/releases/tag/4.0.3

Let me know if that it works OK.