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

Content not updating when switching locales with filament/spatie-laravel-translatable-plugin #85

Closed
naramalkoht opened this issue Mar 2, 2023 · 8 comments · Fixed by #88

Comments

@naramalkoht
Copy link

naramalkoht commented Mar 2, 2023

When using filament/spatie-laravel-translatable-plugin in conjunction with spatie/laravel-translatable, the content of the editor does not update when switching locales using the locale switcher from spatie/laravel-translatable. Specifically, after switching the locale, the content remains the same and does not reflect the updates made for the newly selected locale.

Versions

  • PHP 8.1
  • awcodes/filament-tiptap-edito : 2.2.3
  • filament/filament : 2.17.9
  • laravel/framework : 10.1.5
@awcodes
Copy link
Owner

awcodes commented Mar 4, 2023

Seems like a regression. Will try to solve tomorrow.

@chiiya
Copy link

chiiya commented May 12, 2023

Seems like it only switches correctly for the first instance? When having multiple TiptapEditor fields in a form, only the first one switches locale correctly.

I'm on the latest version (2.2.10)

@awcodes
Copy link
Owner

awcodes commented May 12, 2023

Should be fixed with v2.2.11.

@NicoLeroyDev
Copy link

NicoLeroyDev commented May 15, 2023

Hello !

I still have a strange behaviour using :
awcodes/filament-tiptap-editor v2.2.11
filament/spatie-laravel-translatable-plugin v2.17.40

I have to switch many times before the tiptap editor actually reloads properly...

I have 2 languages, french and english.

On first page load :
Switch and editor both in English, that's good.
I switch to french -> editor still in english.
I switch back to english -> editor still in english (which is good)
I switch back again to french -> editor in french (which is good)

And then I have to repeat the same process to display the editor in english.

The same behaviour occurs either if I have only one editor, or many...

Edit :
Sorry, in config/app.php, I had this : 'locale' => 'fr'. Setting this to 'en' fixed my problem, even if I would prefer keep it like it was ^^...

@awcodes
Copy link
Owner

awcodes commented May 15, 2023

Ok. let me do some more digging. It should be respecting the app's default locale too.

@chiiya
Copy link

chiiya commented May 16, 2023

Yea, it seems to skip the first language switch. I have 3 languages:

  • Defaults to English and displays English content, which is good
  • I switch to German -> nothing happens
  • I switch to French -> content switches to German (previous selection)
  • I switch to English -> content switches to French (previous selection)
    etc.

@awcodes
Copy link
Owner

awcodes commented May 16, 2023

Hmm. I can't replicate the issue. Only thing i'm seeing is that the language switcher doesn't honor the default locale, but that comes down to the order you in which you register the available locales for the resource.

This is with locale => 'fr' in app/config.php.

Screen.Recording.2023-05-16.at.2.13.07.PM.mov

@chiiya
Copy link

chiiya commented May 17, 2023

It only happens with a sufficiently high amount of editor instances.

On my form I originally had 26 TipTapEditors. Locally, it was working fine, however on the staging server the aforementioned issue kept showing up. Once I started adding even more fields (40-50+) I could also observe the same error locally. Not consistently every time, but sometimes the language switch just doesn't update the editor content.

Weirdly enough, the same doesn't happen with the default Filament RichEditor, it just seems to be some kind of overhead this package adds.

Unfortunately I can't spend any more time on researching this error, so I switched to the tiny-editor plugin for now, which doesn't have this issue.

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

Successfully merging a pull request may close this issue.

4 participants