Skip to content

Commit

Permalink
wip: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Nov 11, 2024
1 parent f449fa7 commit c676507
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/Compat/SearchControls.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ public function createSearchBar(Query $query, ...$params): SearchBar
$preserveParams = array_pop($params) ?? [];
$redirectUrl = array_pop($params);

$requestUrlClone = $requestUrl->onlyWith($preserveParams);
$paramsToAdd = $requestUrlClone->getParams();

if ($redirectUrl !== null) {
$redirectUrl->addParams($requestUrl->onlyWith($preserveParams)->getParams()->toArray(false));
$redirectUrl->addParams($paramsToAdd->toArray(false));
} else {
$redirectUrl = $requestUrl->onlyWith($preserveParams);
$redirectUrl = $requestUrlClone;
}

$filter = QueryString::fromString((string) $this->params)
Expand All @@ -83,7 +86,10 @@ public function createSearchBar(Query $query, ...$params): SearchBar
if (method_exists($this, 'completeAction')) {
$searchBar->setSuggestionUrl(Url::fromPath(
"$moduleName/$controllerName/complete",
['_disableLayout' => true, 'showCompact' => true]
$paramsToAdd
->set('_disableLayout', true)
->set('showCompact', true)
->toArray(false)
));
}

Expand Down Expand Up @@ -156,14 +162,13 @@ public function createSearchEditor(Query $query, ...$params): SearchEditor
$redirectUrl = array_pop($params);
$moduleName = $this->getRequest()->getModuleName();
$controllerName = $this->getRequest()->getControllerName();
$paramsToAdd = $requestUrl->onlyWith($preserveParams)->getParams();

if ($redirectUrl !== null) {
$redirectUrl->addParams($requestUrl->onlyWith($preserveParams)->getParams()->toArray(false));
$redirectUrl->addParams($paramsToAdd->toArray(false));
} else {
$redirectUrl = Url::fromPath("$moduleName/$controllerName");
if (! empty($preserveParams)) {
$redirectUrl->setParams($requestUrl->onlyWith($preserveParams)->getParams());
}
$redirectUrl = Url::fromPath("$moduleName/$controllerName")
->setParams($paramsToAdd);
}

$editor = new SearchEditor();
Expand All @@ -174,7 +179,10 @@ public function createSearchEditor(Query $query, ...$params): SearchEditor
if (method_exists($this, 'completeAction')) {
$editor->setSuggestionUrl(Url::fromPath(
"$moduleName/$controllerName/complete",
['_disableLayout' => true, 'showCompact' => true]
$paramsToAdd
->set('_disableLayout', true)
->set('showCompact', true)
->toArray(false)
));
}

Expand Down

0 comments on commit c676507

Please sign in to comment.