This repository was archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Error in live preview "change" event #13
Copy link
Copy link
Open
Description
Hi, it seems like the handling of the change event in the storyblokBridge live preview is causing the following error:
storyblokBridge.js?3678:15 Uncaught TypeError: Cannot read properties of undefined (reading 'content')
at m.eval (storyblokBridge.js?3678:15)
at m.emit (storyblok-v2-latest.js:1)
at m.receiveMessageFromApp (storyblok-v2-latest.js:1)Upon further investigation it seems like the error happens when trying to access the payload.story.content property during the handling of the change event.
const storyblokBridge = (
content = { content: {} },
events = ['change', 'input'],
relations = [],
) => {
if (window) {
// eslint-disable-next-line
const instance = new StoryblokBridge({
resolveRelations: relations,
})
instance.on(events, (payload) => {
content.content = {
...payload.story.content, // <--- HERE
_meta: payload.story,
}
})
}
}According to the Storyblok event docs the change event only has the following properties:
{
"reload": true,
"action": "change", // or published
"slug": "home",
"storyId": 24840769,
"slugChanged": true
}Not sure what the fix would be for this, the change event should probably be handled in a different way.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels