Skip to content

Commit

Permalink
fix: sticky buttons with action button show in dropdown
Browse files Browse the repository at this point in the history
issue #1462
  • Loading branch information
DissNik committed Jan 9, 2025
1 parent e9d9160 commit 7beec94
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/UI/resources/css/components/tables.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,9 @@ th,
td {
&.sticky-col {
@apply md:sticky md:backdrop-blur;

&:has(.dropdown-body.visible) {
@apply z-1;
}
}
}
3 changes: 2 additions & 1 deletion src/UI/resources/js/Components/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ export default () => ({
}

const dropdownPlacement = this.$root.dataset.dropdownPlacement
const dropdownStrategy = this.$root.dataset.dropdownStrategy

this.popperInstance = createPopper(this.dropdownBtn, this.dropdownBody, {
placement: dropdownPlacement ? dropdownPlacement : 'auto',
strategy: 'fixed',
strategy: dropdownStrategy ? dropdownStrategy : 'fixed',
modifiers: [
{
name: 'offset',
Expand Down
2 changes: 1 addition & 1 deletion src/UI/resources/views/components/action-group.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@if(count($actions))
<div {{ $attributes->merge(['class' => 'flex items-center gap-2']) }}>
@if($actions->inDropdown()->isNotEmpty())
<x-moonshine::dropdown>
<x-moonshine::dropdown strategy="absolute">
<x-slot:toggler class="btn">
<x-moonshine::icon icon="ellipsis-vertical" />
</x-slot:toggler>
Expand Down
2 changes: 2 additions & 0 deletions src/UI/resources/views/components/dropdown.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
'searchable' => false,
'searchPlaceholder' => '',
'footer' => null,
'strategy' => 'fixed',
])
<div x-data="dropdown"
@click.outside="closeDropdown"
data-dropdown-strategy="{{ $strategy }}"
data-dropdown-placement="{{ $placement }}"
data-searchable="{{$searchable}}"
class="dropdown"
Expand Down
10 changes: 10 additions & 0 deletions src/UI/src/Components/Dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function __construct(
protected Closure|string $searchPlaceholder = '',
public string $placement = 'bottom-start',
public Closure|string $footer = '',
public string $strategy = 'fixed',
) {
parent::__construct();
}
Expand Down Expand Up @@ -89,6 +90,14 @@ public function footer(Closure|string $value): self
return $this;
}


public function strategy(string $strategy): self
{
$this->strategy = $strategy;

return $this;
}

/**
* @return array<string, mixed>
*/
Expand All @@ -101,6 +110,7 @@ protected function viewData(): array
'searchable' => $this->searchable,
'searchPlaceholder' => value($this->searchPlaceholder, $this),
'items' => value($this->items, $this),
'strategy' => $this->strategy,
];
}
}

0 comments on commit 7beec94

Please sign in to comment.