Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rich text editor is empty when page refreshed #738

Open
lloydowen opened this issue Nov 25, 2024 · 8 comments
Open

Rich text editor is empty when page refreshed #738

lloydowen opened this issue Nov 25, 2024 · 8 comments

Comments

@lloydowen
Copy link

lloydowen commented Nov 25, 2024

When using a element like this:

<flux:editor wire:model="content" label="Content" description="Contract in Markdown "/>

However, if i refresh the page, or navigate via a traditional link the editor is initialised with no content.

When I navigate to a page with an editor using wire:navigate, the content displays as expected.

I am filling the page on the mount method i.e.:

  public function mount()
  {
      $this->fill($this->template->toArray());
  }

At this point, $content is filled with valid HTML (previously saved with the editor).

Which is filling the $content property on the livewire component:

    #[Validate('required')]
    public ?string $content = '';

There are no errors in the console to report.

@jeffchown
Copy link

@lloydowen Can you provide full code that can be copy/pasted to reproduce the issue? Volt components are great, when possible.

@lloydowen
Copy link
Author

sure,

<?php

use Livewire\Volt\Component;

new class extends Component {
    public $content = '<h1>Hello World</h1>';
}; ?>

<div>
    <flux:editor wire:model="content" />
</div>

results in:
Image

but adding wire:model.live for example:

<?php

use Livewire\Volt\Component;

new class extends Component {
    public $content = '<h1>Hello World</h1>';
}; ?>

<div>
    <flux:editor wire:model.live="content" />
</div>

results in it working as expected:
Image

@jeffchown
Copy link

jeffchown commented Nov 25, 2024

@lloydowen I tried your first example, and can't recreate the issue.
With just wire:model="content", it works for me:

Image

Have you run npm run build and php artisan view:clear to be sure all is compiled and refreshed?

@lloydowen
Copy link
Author

Yes, i've tried that.

Even if i output the content it's definitely there:

<?php

use Livewire\Volt\Component;

new class extends Component {
    public string $content = '<h1>Hello World</h1>';
}; ?>

<div>
    <flux:editor wire:model="content"/>
    <div class="prose dark:prose-invert">
        {!! $content !!}
    </div>
</div>

Image

It only works with .live which i'll use for now. Sorry i don't have anymore logs to share. If i get some extra downtime i'll dive deeper into it, sharing in case it was a wider issue.

@jeffchown
Copy link

@lloydowen Very strange. Have you inspected the flux:editor using devtools to see if the content is maybe there but styled in a way that makes it invisible?

Good luck with the deeper dive. I'm curious to hear what might be causing it.

@jeffchown
Copy link

jeffchown commented Nov 25, 2024

@lloydowen PS Plus make sure you are using Flux v1.0.27 as v1.0.26 had a dependency error.

@sewid
Copy link

sewid commented Nov 26, 2024

Same problem here - in combination with a Livewire Form. When I browse to the edit form using wire:navigate, the editor shows the desired content. If I refresh the page or browse to the page without wire:navigate, the editor is empty.

There is no error in the dev console and there is no content in the editor (checked using dev console).

As an addition, the editor is within a form tag. And the submit button is not working, is on the page. If I swap the editor to a textarea, everything works fine.

@lloydowen
Copy link
Author

lloydowen commented Nov 27, 2024

This seems to be fixed since v1.0.28

Ignore that, confirmed still an issue in v1.0.28

@lloydowen lloydowen reopened this Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants