Repository navigation
fix: drive translation tabs with an own Alpine component - #42
Merged
Merged
Conversation
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
There was a problem hiding this comment.
🔵 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.
Contributor
Author
|
Addressed Copilot's note in bc577bc: the component now uses |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since Filament 5.10.2 (and 4.16),
tabsSchemaComponentexpects the markup of Filament's own tabs view ([x-ref=tabsHeader] > [x-ref=tablist] > [data-tab-key]). TheTranslationsview renders its own markup, so the component throwsCannot read properties of null (reading 'querySelectorAll')on init and no tab panel becomes active.Fix
translationsTabsComponent(resources/dist/components/translations-tabs.js), registered viaFilamentAssetand loaded by the view instead of Filament's. It keeps the 5.10.1 behaviour the view relies on: tab list from the hiddentabsDatainput, default tab, query-string persistence, Livewire re-sync, autofocus. The scroll/overflow dropdown is left out, since this view never rendered one.Verification
Users need to run
php artisan filament:assetsafter upgrading.Fixes #37