@@ -58,10 +58,13 @@ public function createSearchBar(Query $query, ...$params): SearchBar
58
58
$ preserveParams = array_pop ($ params ) ?? [];
59
59
$ redirectUrl = array_pop ($ params );
60
60
61
+ $ paramsToAdd = $ requestUrl ->onlyWith ($ preserveParams )->getParams ()->toArray (false );
62
+
61
63
if ($ redirectUrl !== null ) {
62
- $ redirectUrl ->addParams ($ requestUrl -> onlyWith ( $ preserveParams )-> getParams ()-> toArray ( false ) );
64
+ $ redirectUrl ->addParams ($ paramsToAdd );
63
65
} else {
64
- $ redirectUrl = $ requestUrl ->onlyWith ($ preserveParams );
66
+ $ redirectUrl = clone $ requestUrl ;
67
+ $ redirectUrl ->setParams ($ paramsToAdd );
65
68
}
66
69
67
70
$ filter = QueryString::fromString ((string ) $ this ->params )
@@ -83,7 +86,7 @@ public function createSearchBar(Query $query, ...$params): SearchBar
83
86
if (method_exists ($ this , 'completeAction ' )) {
84
87
$ searchBar ->setSuggestionUrl (Url::fromPath (
85
88
"$ moduleName/ $ controllerName/complete " ,
86
- ['_disableLayout ' => true , 'showCompact ' => true ]
89
+ array_merge ( $ paramsToAdd , ['_disableLayout ' => true , 'showCompact ' => true ])
87
90
));
88
91
}
89
92
@@ -156,13 +159,14 @@ public function createSearchEditor(Query $query, ...$params): SearchEditor
156
159
$ redirectUrl = array_pop ($ params );
157
160
$ moduleName = $ this ->getRequest ()->getModuleName ();
158
161
$ controllerName = $ this ->getRequest ()->getControllerName ();
162
+ $ paramsToAdd = $ requestUrl ->onlyWith ($ preserveParams )->getParams ()->toArray (false );
159
163
160
164
if ($ redirectUrl !== null ) {
161
- $ redirectUrl ->addParams ($ requestUrl -> onlyWith ( $ preserveParams )-> getParams ()-> toArray ( false ) );
165
+ $ redirectUrl ->addParams ($ paramsToAdd );
162
166
} else {
163
167
$ redirectUrl = Url::fromPath ("$ moduleName/ $ controllerName " );
164
- if (! empty ($ preserveParams )) {
165
- $ redirectUrl ->setParams ($ requestUrl -> onlyWith ( $ preserveParams )-> getParams () );
168
+ if (! empty ($ paramsToAdd )) {
169
+ $ redirectUrl ->setParams ($ paramsToAdd );
166
170
}
167
171
}
168
172
@@ -174,7 +178,7 @@ public function createSearchEditor(Query $query, ...$params): SearchEditor
174
178
if (method_exists ($ this , 'completeAction ' )) {
175
179
$ editor ->setSuggestionUrl (Url::fromPath (
176
180
"$ moduleName/ $ controllerName/complete " ,
177
- ['_disableLayout ' => true , 'showCompact ' => true ]
181
+ array_merge ( $ paramsToAdd , ['_disableLayout ' => true , 'showCompact ' => true ])
178
182
));
179
183
}
180
184
0 commit comments