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

Unable to insert a Builder block between others in a multilingual setup #11541

Closed
AlexisSerneels opened this issue Feb 23, 2024 · 1 comment · Fixed by #12355
Closed

Unable to insert a Builder block between others in a multilingual setup #11541

AlexisSerneels opened this issue Feb 23, 2024 · 1 comment · Fixed by #12355
Milestone

Comments

@AlexisSerneels
Copy link
Contributor

Package

filament/filament

Package Version

v3.2.35

Laravel Version

v10.45.1

Livewire Version

No response

PHP Version

PHP 8.3.3

Problem description

When a Builder is used in a Resource managed by filament/spatie-laravel-translatable-plugin, the error Undefined array key "afterItem" is returned when trying to insert a block between others.

I was able to trace the error to this line and it arises because the blocks for translations do not have a UUID:

if ($uuid === $arguments['afterItem']) {

Here is the dump for the $arguments when saving in English:
CleanShot 2024-02-23 at 09 50 18@2x

Here is the dump for the $arguments when saving in other languages.
We can see the UUID and afterItem key is missing.
CleanShot 2024-02-23 at 09 51 00@2x

Here is the full error in video:

CleanShot.2024-02-23.at.09.48.40.mp4

Expected behavior

No error should occur.

Steps to reproduce

  • Clone the repository.
  • Migrate
  • Seed
  • Go to Products, edit any.
  • Switch to FRENCH
  • Try inserting a block between the two existing.

CleanShot 2024-02-23 at 09 47 32@2x

Reproduction repository

https://github.com/AlexisSerneels/filament-issue

Relevant log output

No response

@zepfietje zepfietje added this to the v3 milestone Feb 28, 2024
dmitry-udod added a commit to dmitry-udod/filament that referenced this issue Apr 16, 2024
@dmitry-udod
Copy link
Contributor

@AlexisSerneels Hi! There are two reasons why this happens: When you switch the locale to French in your example, the spatie-laravel-translatable-plugin resets the data array keys from uuid's to integers (plugin code). Then, in our block-picker.blade.php, we have an if statement where we check that the $afterItem variable is set, but because it has a zero value, it fails. See the video below, please:

Screencast.2024-04-16.15.53.15.mp4

As a quick solution you can create a new class that extends Filament\Forms\Components\Builder\Block and create custom view for it with "isset" fix.

@dmitry-udod dmitry-udod mentioned this issue Apr 16, 2024
3 tasks
@danharrin danharrin linked a pull request Apr 16, 2024 that will close this issue
3 tasks
danharrin added a commit that referenced this issue Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants