Skip to content

Commit 43d1fe5

Browse files
ContinueWith: Disable button if the query with filter returns no results
1 parent 3e8867c commit 43d1fe5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Widget/ContinueWith.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ class ContinueWith extends BaseHtmlElement
2727
/** @var string */
2828
protected $title;
2929

30-
public function __construct(Url $url, $filter)
30+
/** @var bool Whether the current query has results */
31+
protected bool $hasResults = true;
32+
33+
public function __construct(Url $url, $filter, bool $hasResults = true)
3134
{
3235
$this->url = $url;
3336
$this->filter = $filter;
37+
$this->hasResults = $hasResults;
3438
}
3539

3640
/**
@@ -59,7 +63,7 @@ public function assemble()
5963
$filter = Filter::all($baseFilter, $filter);
6064
}
6165

62-
if ($filter instanceof Filter\Chain && $filter->isEmpty()) {
66+
if (! $this->hasResults || ($filter instanceof Filter\Chain && $filter->isEmpty())) {
6367
$this->addHtml(new HtmlElement(
6468
'span',
6569
Attributes::create(['class' => ['control-button', 'disabled']]),

0 commit comments

Comments
 (0)