Dynamically injecting content to MarkdownEditor fails

Hey All, I have a wizard with 2 steps, the first step contains a select to choose a markdown template, the second step has the content injected to the markdown editor, allowing to user to make minor edits if necessary. Running into issues attempting to push content to the Markdown component . This works fine the first time, but changing the selection and navigating back to the second step 2 things happen: 1) The content is not updated 2) Clicking into the Markdown Editor seems to inject "invisible" content and throws a JS error in markdown-editor.js Uncaught TypeError: i is undefined
Actions\Action::make('updateBlogContent')
->steps([
Step::make('markdown-template')
->schema([
FormComponents\Select::make('template')
->options(fn () => MarkdownTemplate::all()->pluck('name', 'id')->toArray())
->required()
->live()
->afterStateUpdated(function ($state, Set $set) {
$template = MarkdownTemplate::find($state);
$set('content', $template->content);
}),
]),
Step::make('blog-content')
->schema([
FormComponents\MarkdownEditor::make('content')
]),
]),
Actions\Action::make('updateBlogContent')
->steps([
Step::make('markdown-template')
->schema([
FormComponents\Select::make('template')
->options(fn () => MarkdownTemplate::all()->pluck('name', 'id')->toArray())
->required()
->live()
->afterStateUpdated(function ($state, Set $set) {
$template = MarkdownTemplate::find($state);
$set('content', $template->content);
}),
]),
Step::make('blog-content')
->schema([
FormComponents\MarkdownEditor::make('content')
]),
]),
I have tried adding ->live() to the MarkdownEditor, but no such luck. Any help is appreciated!
2 Replies
edwardwestbury
edwardwestburyOPβ€’15mo ago
Update: No issues if I use a RichEditor component, seems like an issue with the MarkdownEditor component itself
Log1x
Log1xβ€’15mo ago
ran into this as well. i think it's an issue with EasyMDE as I've experienced this in the past – not sure if there's a possible fix. 😦
Want results from more Discord servers?
Add your server