You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The method FilamentShield::getLocalizedWidgetLabel($widget['class']) in HasShieldFormComponents.php is unable to generate the permission label for Counter widgets. This issue occurs because the getHeading() method is inherited from BaseWidget for Counter widgets, which always evaluates as true in the following code: $widgetInstance = app()->make($widget); return match (true) { $widgetInstance instanceof TableWidget => (string) invade($widgetInstance)->makeTable()->getHeading(), !($widgetInstance instanceof TableWidget) && $widgetInstance instanceof Widget && method_exists($widgetInstance, 'getHeading') => (string) invade($widgetInstance)->getHeading(), default => str($widget)->afterLast('\\')->headline()->toString(), };
Since getHeading() is defined in BaseWidget, the condition always evaluates to true, even when no actual heading is set for the Counter widget. As a result, the widget name is not displayed when no heading is provided for Counter widgets.
To resolve this issue, we should modify the condition on line 313 in filament-shield.php to ensure that a non-null heading is required for Counter widgets. The fix could look like this: !($widgetInstance instanceof TableWidget) && $widgetInstance instanceof Widget && method_exists($widgetInstance, 'getHeading') && invade($widgetInstance)->getHeading() != null
This will prevent the method from returning a label for Counter widgets when no heading is explicitly set, im not sure if its a clean way to handle this issue or not ,
The text was updated successfully, but these errors were encountered:
The method FilamentShield::getLocalizedWidgetLabel($widget['class']) in HasShieldFormComponents.php is unable to generate the permission label for Counter widgets. This issue occurs because the getHeading() method is inherited from BaseWidget for Counter widgets, which always evaluates as true in the following code:
$widgetInstance = app()->make($widget); return match (true) { $widgetInstance instanceof TableWidget => (string) invade($widgetInstance)->makeTable()->getHeading(), !($widgetInstance instanceof TableWidget) && $widgetInstance instanceof Widget && method_exists($widgetInstance, 'getHeading') => (string) invade($widgetInstance)->getHeading(), default => str($widget)->afterLast('\\')->headline()->toString(), };
Since getHeading() is defined in BaseWidget, the condition always evaluates to true, even when no actual heading is set for the Counter widget. As a result, the widget name is not displayed when no heading is provided for Counter widgets.
To resolve this issue, we should modify the condition on line 313 in filament-shield.php to ensure that a non-null heading is required for Counter widgets. The fix could look like this:
!($widgetInstance instanceof TableWidget) && $widgetInstance instanceof Widget && method_exists($widgetInstance, 'getHeading') && invade($widgetInstance)->getHeading() != null
This will prevent the method from returning a label for Counter widgets when no heading is explicitly set, im not sure if its a clean way to handle this issue or not ,
The text was updated successfully, but these errors were encountered: