fix: Preserve hint tooltip on single-arg hintIcon (#19626)

This commit is contained in:
Daniel Haaker
2026-04-03 14:11:23 +01:00
committed by GitHub
parent 33a4378170
commit c9b6ecd0fb
4 changed files with 67 additions and 2 deletions
@@ -109,7 +109,10 @@ trait HasHint
public function hintIcon(string | BackedEnum | Htmlable | Closure | null $icon, string | Closure | null $tooltip = null): static
{
$this->hintIcon = $icon;
$this->hintIconTooltip($tooltip);
if (func_num_args() >= 2) {
$this->hintIconTooltip($tooltip);
}
return $this;
}
@@ -108,7 +108,10 @@ trait HasHint
public function hintIcon(string | BackedEnum | Htmlable | Closure | null $icon, string | Closure | null $tooltip = null): static
{
$this->hintIcon = $icon;
$this->hintIconTooltip($tooltip);
if (func_num_args() >= 2) {
$this->hintIconTooltip($tooltip);
}
return $this;
}
+28
View File
@@ -77,3 +77,31 @@ class TestComponentWithFormWithTestFieldHint extends Livewire
->statePath('data');
}
}
it('can set a hint icon tooltip via hintIcon second parameter', function (): void {
$field = TextInput::make('test')
->container(Schema::make(Livewire::make()))
->hintIcon('heroicon-o-information-circle', 'Example tooltip');
expect($field->getHintIconTooltip())
->toBe('Example tooltip');
});
it('does not clear a previously set hint icon tooltip when calling hintIcon without a tooltip', function (): void {
$field = TextInput::make('test')
->container(Schema::make(Livewire::make()))
->hintIconTooltip('Example tooltip')
->hintIcon('heroicon-o-information-circle');
expect($field->getHintIconTooltip())
->toBe('Example tooltip');
});
it('can clear a previously set hint icon tooltip by explicitly passing null to hintIcon', function (): void {
$field = TextInput::make('test')
->container(Schema::make(Livewire::make()))
->hintIconTooltip('Example tooltip')
->hintIcon('heroicon-o-information-circle', null);
expect($field->getHintIconTooltip())
->toBeNull();
});
+31
View File
@@ -1,6 +1,8 @@
<?php
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Schema;
use Filament\Tests\Fixtures\Livewire\Livewire;
use Filament\Tests\Tables\TestCase;
uses(TestCase::class);
@@ -26,3 +28,32 @@ class IdEntry extends TextEntry
return 'id';
}
}
it('can set a hint icon tooltip via hintIcon second parameter', function (): void {
$entry = TextEntry::make('test')
->container(Schema::make(Livewire::make()))
->hintIcon('heroicon-o-information-circle', 'Example tooltip');
expect($entry->getHintIconTooltip())
->toBe('Example tooltip');
});
it('does not clear a previously set hint icon tooltip when calling hintIcon without a tooltip', function (): void {
$entry = TextEntry::make('test')
->container(Schema::make(Livewire::make()))
->hintIconTooltip('Example tooltip')
->hintIcon('heroicon-o-information-circle');
expect($entry->getHintIconTooltip())
->toBe('Example tooltip');
});
it('can clear a previously set hint icon tooltip by explicitly passing null to hintIcon', function (): void {
$entry = TextEntry::make('test')
->container(Schema::make(Livewire::make()))
->hintIconTooltip('Example tooltip')
->hintIcon('heroicon-o-information-circle', null);
expect($entry->getHintIconTooltip())
->toBeNull();
});