Skip to content

fix: drive translation tabs with an own Alpine component - #42

Merged
webard merged 2 commits into
5.xfrom
fix/translations-tabs-filament-5-10-2
Nov 2, 2026
Merged

webard merged 2 commits into
5.xfrom
fix/translations-tabs-filament-5-10-2

Conversation

@webard

@webard webard commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Since Filament 5.10.2 (and 4.16), tabsSchemaComponent expects the markup of Filament's own tabs view ([x-ref=tabsHeader] > [x-ref=tablist] > [data-tab-key]). The Translations view renders its own markup, so the component throws Cannot read properties of null (reading 'querySelectorAll') on init and no tab panel becomes active.

Fix

  • Ship an own Alpine component, translationsTabsComponent (resources/dist/components/translations-tabs.js), registered via FilamentAsset and loaded by the view instead of Filament's. It keeps the 5.10.1 behaviour the view relies on: tab list from the hidden tabsData input, default tab, query-string persistence, Livewire re-sync, autofocus. The scroll/overflow dropdown is left out, since this view never rendered one.
  • Regression test asserting the view uses the package component, not Filament's.

Verification

  • Test suite, PHPStan and Pint pass on Filament 5.11.0 and 4.16.0.
  • Component run in Alpine + jsdom: first tab active on init, click switches panels.
  • Not yet checked in a real panel in the browser.

Users need to run php artisan filament:assets after upgrading.

Fixes #37

Filament 5.10.2 and 4.16 rewrote tabsSchemaComponent, which now expects the
markup of Filament's own tabs view (x-ref=tabsHeader / tablist). The
Translations view renders its own markup, so the component failed to
initialise and no tab panel became active.

Fixes #37
Copilot AI balanced review requested due to automatic review settings November 2, 2026 14:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The unconditional Livewire 4 API call throws during Alpine initialization on supported Filament 4 installations using Livewire 3, preventing registration of the tab re-sync handler.

No open issues 🎉

What changed in this PR

This PR addresses #37 by replacing Filament’s markup-dependent tabs component with a package-owned Alpine component for translation tabs.

Changes:

  • Adds a translation-tabs component for tab selection, query-string persistence, Livewire re-sync, and autofocus.
  • Registers the JavaScript asset and updates the Blade view to load it.
  • Adds a regression test verifying that the view uses the package component.
File Description
tests/​Feature/​ReviewRegressionsTest.php Verifies the package component and asset are used.
src/​FilamentTranslatableServiceProvider.php Registers the translation-tabs Alpine asset.
resources/​views/​forms/​components/​translations.blade.php Switches to the package-owned component.
resources/​dist/​components/​translations-tabs.js Implements translation-tab behavior independently of Filament’s markup.

Review effort: Balanced

Livewire.interceptMessage only exists in Livewire 4. Filament 4 runs on
Livewire 3, so fall back to the commit hook there.
@webard

webard commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Addressed Copilot's note in bc577bc: the component now uses Livewire.interceptMessage when present (Livewire 4 / Filament 5) and falls back to Livewire.hook('commit') on Livewire 3 (Filament 4). Both paths checked in Alpine + jsdom.

@webard
webard merged commit 2f68ad2 into 5.x Nov 2, 2026
23 checks passed
@webard
webard deleted the fix/translations-tabs-filament-5-10-2 branch November 2, 2026 14:25
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 this pull request may close these issues.

[Bug]: Translations tabs render empty on Filament 5.10.2 (tabsSchemaComponent markup mismatch)

2 participants