Skip to content

Commit b7da98f

Browse files
authored
Fix SearchControls trait (#1388)
#1046 introduced two problems to the `SearchControls` trait. Returning `false` from `SearchControls::callHandleRequest()` prevents the ipl-web `SearchControls` trait from calling `handleRequest()` in both `createSearchBar()` and `createSearchEditor()`. An implementation of `createSearchEditor()` is added, which explicitly calls `$editor->handleRequest()` as `createSearchBar()` already does. Without this no `SearchEditor` in the entire module is usable. An other problem is that moving the call of `$searchbar->handleRequest()` also delayed its `assemble()`, so this if block was entered before the assemble, resulting in the wrapper being added twice. ``` if (($wrapper = $searchBar->getWrapper()) && ! $wrapper->getWrapper()) { // TODO: Remove this once ipl-web v0.7.0 is required $searchBar->addWrapper(Html::tag('div', ['class' => 'search-controls'])); } ``` which caused a visual bug: <img width="447" height="175" alt="Screenshot from 2026-06-25 11-01-42" src="https://github.com/user-attachments/assets/4e852585-c677-4c70-8f95-631601294de4" /> The statement should be safe to remove together with the less that has the same `TODO`.
2 parents 17e8498 + 60d1578 commit b7da98f

2 files changed

Lines changed: 16 additions & 52 deletions

File tree

library/Icingadb/Common/SearchControls.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
namespace Icinga\Module\Icingadb\Common;
77

88
use Icinga\Module\Icingadb\Hook\SearchColumnsProviderHook;
9-
use ipl\Html\Html;
109
use ipl\Orm\Query;
1110
use ipl\Web\Control\SearchBar;
11+
use ipl\Web\Control\SearchEditor;
1212
use ipl\Web\Url;
1313
use ipl\Web\Widget\ContinueWith;
1414

1515
trait SearchControls
1616
{
1717
use \ipl\Web\Compat\SearchControls {
1818
\ipl\Web\Compat\SearchControls::createSearchBar as private webCreateSearchBar;
19+
\ipl\Web\Compat\SearchControls::createSearchEditor as private webCreateSearchEditor;
1920
}
2021

2122
/**
@@ -31,11 +32,6 @@ public function createSearchBar(Query $query, ...$params): SearchBar
3132
{
3233
$searchBar = $this->webCreateSearchBar($query, ...$params);
3334

34-
if (($wrapper = $searchBar->getWrapper()) && ! $wrapper->getWrapper()) {
35-
// TODO: Remove this once ipl-web v0.7.0 is required
36-
$searchBar->addWrapper(Html::tag('div', ['class' => 'search-controls']));
37-
}
38-
3935
$model = $query->getModel();
4036
$defaultColumns = $model->getSearchColumns();
4137
$columns = SearchColumnsProviderHook::getCustomVarColumns($model, $defaultColumns);
@@ -51,6 +47,20 @@ private function callHandleRequest()
5147
return false;
5248
}
5349

50+
/**
51+
* Necessary because {@see self::callHandleRequest()} prevents the {@see webCreateSearchEditor()} from calling
52+
* $editor->handleRequest()
53+
*
54+
* @inheritdoc
55+
*/
56+
public function createSearchEditor(Query $query, ...$params): SearchEditor
57+
{
58+
$editor = $this->webCreateSearchEditor($query, ...$params);
59+
$editor->handleRequest($this->getServerRequest());
60+
61+
return $editor;
62+
}
63+
5464
/**
5565
* Create and return a ContinueWith
5666
*

public/css/common.less

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -107,52 +107,6 @@ div.show-more {
107107
.notice {
108108
display: none;
109109
}
110-
111-
// TODO: Remove once ipl-web v0.7.0 is required
112-
&:not(.default-layout) {
113-
.pagination-control {
114-
float: left;
115-
}
116-
117-
.sort-control {
118-
display: flex;
119-
justify-content: flex-end;
120-
121-
:not(.form-element) > label {
122-
margin-right: 0;
123-
}
124-
125-
.control-button {
126-
margin: 0;
127-
}
128-
}
129-
130-
> :not(:only-child) {
131-
margin-bottom: 0.5em;
132-
}
133-
134-
.search-suggestions {
135-
margin-bottom: 2.5em;
136-
}
137-
138-
.search-controls {
139-
clear: both;
140-
display: flex;
141-
min-width: 100%;
142-
143-
.search-bar {
144-
flex: 1 1 auto;
145-
146-
& ~ .control-button:last-child {
147-
margin-right: -.5em;
148-
}
149-
150-
& ~ .control-button {
151-
margin-left: .5em;
152-
}
153-
}
154-
}
155-
}
156110
}
157111

158112
.content > h2:first-child,

0 commit comments

Comments
 (0)