Skip to content

Fix TypeError in tabs.js for non-scrollable Translate tabs#38

Open
buzkall wants to merge 1 commit intosolutionforest:3.xfrom
buzkall:fix/tabs-scrollable-error
Open

Fix TypeError in tabs.js for non-scrollable Translate tabs#38
buzkall wants to merge 1 commit intosolutionforest:3.xfrom
buzkall:fix/tabs-scrollable-error

Conversation

@buzkall
Copy link
Copy Markdown

@buzkall buzkall commented Mar 30, 2026

Problem

When using the Translate component on a Filament 5 page, the browser console throws:

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'clientWidth')
    at Proxy.calculateDropdownIconWidth (tabs.js)
    at Proxy.updateTabsWithinDropdown (tabs.js)

Root Cause

The translate.blade.php template loads Filament's tabsSchemaComponent Alpine component without passing isScrollable, which defaults to false. This triggers the non-scrollable dropdown overflow logic in tabs.js, which expects a dropdown trigger element (.fi-tabs-item:last-child containing a .fi-icon) to be present in the DOM.

However, the Translate component renders tabs using <x-filament::tabs> (the presentation component) which does not include the dropdown trigger markup that Filament 5's native tabs.blade.php schema component renders (lines 167-209). When updateTabsWithinDropdown() runs, triggerEl.querySelector('.fi-icon') returns null, causing the crash.

Fix

Pass isScrollable: true to tabsSchemaComponent in the Alpine data. This skips the dropdown overflow logic entirely, which is appropriate since locale/translation tabs are always a small fixed set and don't need responsive overflow handling.

The Translate component loads Filament's tabsSchemaComponent without
passing isScrollable, which defaults to false. This triggers the
dropdown overflow logic in tabs.js that expects a dropdown trigger
element (.fi-tabs-item:last-child with .fi-icon), but the Translate
template never renders this markup — causing:

  TypeError: Cannot read properties of null (reading 'clientWidth')

Pass isScrollable: true to skip the dropdown logic, which is not
needed for locale tabs.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a client-side crash in Filament 5 tabs initialization when the Translate form component renders non-scrollable tabs markup that lacks Filament’s dropdown-trigger element expected by the tabsSchemaComponent overflow logic.

Changes:

  • Pass isScrollable: true into Filament’s tabsSchemaComponent Alpine initializer for the Translate component.
  • Avoid triggering the non-scrollable “tabs within dropdown” overflow logic path that was causing a null dereference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants