Skip to content

Commit

Permalink
fix: disable column click when used in a relation manager
Browse files Browse the repository at this point in the history
  • Loading branch information
dmandrade committed Jan 17, 2024
1 parent 2b6a58a commit 363215d
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/Tables/CopyableTextColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Webbingbrasil\FilamentCopyActions\Tables;

use Closure;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Columns\TextColumn;

class CopyableTextColumn extends TextColumn
Expand All @@ -17,18 +18,20 @@ class CopyableTextColumn extends TextColumn

public function setUp(): void
{
$this->copyableState(function ($state) {
$copyDescription = (bool) $this->evaluate($this->copyWithDescription);
if ($copyDescription) {
$state = implode("\r\n", array_filter([
$this->getDescriptionAbove(),
$state,
$this->getDescriptionBelow(),
]));
}

return $state;
});
$this
->disabledClick(fn ($livewire) => is_a($livewire, RelationManager::class))
->copyableState(function ($state) {
$copyDescription = (bool) $this->evaluate($this->copyWithDescription);
if ($copyDescription) {
$state = implode("\r\n", array_filter([
$this->getDescriptionAbove(),
$state,
$this->getDescriptionBelow(),
]));
}

return $state;
});
}

public function onlyIcon(bool | Closure $isOnlyIcon = true): static
Expand Down

0 comments on commit 363215d

Please sign in to comment.