You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to paste content into a blocks field which doesn't have all the needed blocks enabled, the following error shows:
Spread syntax requires ...iterable[Symbol.iterator] to be a function
Expected behavior
The available blocks should be pasted.
To reproduce
Blueprint:
fields:
blocks:
fieldsets:
text: blocks/text
Copy this issue (make sure to include the headings)
Paste it into the blocks field
See error
Your setup
Kirby Version
4.0.0 beta 2
Your system (please complete the following information)
Device: Desktop PC
OS: Windows 11
Browser: Chrome
Version: 118
PHP: 8.2
Additional context
The pasteBlocks function removes unavailable blocks from the parsed input using unset. unset, however, leaves the key => value association of the remaining entries intact. This creates a sparse array which, when serialized to JSON, gets transformed into an object rather than an array:
{"1": { ... }"3": { ... }"7": { ... }}
This causes an the error here, when trying to spread that object into the splice function.
Making sure the pasteBlocks function returns a dense array, either by creating a new array and copying available blocks to it (rather than removing unavailable ones), or by creating a new one with return array_values($blocks) seems to sove this issue (there seem to be other issues involving pasting blocks, but I'm unsure if that isn't caused by my particular setup).
The text was updated successfully, but these errors were encountered:
Description
When trying to paste content into a blocks field which doesn't have all the needed blocks enabled, the following error shows:
Expected behavior
The available blocks should be pasted.
To reproduce
Your setup
Kirby Version
4.0.0 beta 2
Your system (please complete the following information)
Additional context
The pasteBlocks function removes unavailable blocks from the parsed input using
unset
.unset
, however, leaves thekey => value
association of the remaining entries intact. This creates a sparse array which, when serialized to JSON, gets transformed into an object rather than an array:This causes an the error here, when trying to spread that object into the splice function.
Making sure the
pasteBlocks
function returns a dense array, either by creating a new array and copying available blocks to it (rather than removing unavailable ones), or by creating a new one withreturn array_values($blocks)
seems to sove this issue (there seem to be other issues involving pasting blocks, but I'm unsure if that isn't caused by my particular setup).The text was updated successfully, but these errors were encountered: