[FIX] web: the search bar input should be trimmed
Steps to follow - Go to the Sales app - Search for a entry with a space at the end -> No results are returned The search input should be trimmed, it was in 13.0 opw-2803156 closes odoo/odoo#87529 X-original-commit: 06817417e190d64ab6b0fc6151e02b6090b1fd39 Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
This commit is contained in:
@@ -275,7 +275,7 @@ odoo.define('web.SearchBar', function (require) {
|
||||
// - Selection sources
|
||||
// - "no result" items
|
||||
if (source.active) {
|
||||
const labelValue = source.label || this.state.inputValue;
|
||||
const labelValue = source.label || this.state.inputValue.trim();
|
||||
this.model.dispatch('addAutoCompletionValues', {
|
||||
filterId: source.filterId,
|
||||
value: "value" in source ? source.value : this._parseWithSource(labelValue, source),
|
||||
|
||||
@@ -251,6 +251,38 @@ QUnit.module("Search Bar (legacy)", (hooks) => {
|
||||
"a", "There should be a field facet with label 'a'");
|
||||
});
|
||||
|
||||
QUnit.test('autocomplete input is trimmed', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
let searchReadCount = 0;
|
||||
const webClient = await createWebClient({
|
||||
serverData,
|
||||
mockRPC: (route, args) => {
|
||||
if (route === '/web/dataset/search_read') {
|
||||
switch (searchReadCount) {
|
||||
case 0:
|
||||
// Done on loading
|
||||
break;
|
||||
case 1:
|
||||
assert.deepEqual(args.domain, [["foo", "ilike", "a"]]);
|
||||
break;
|
||||
}
|
||||
searchReadCount++;
|
||||
}
|
||||
}
|
||||
});
|
||||
await doAction(webClient, 1);
|
||||
|
||||
const searchInput = target.querySelector('.o_searchview_input');
|
||||
await testUtils.fields.editInput(searchInput, 'a ');
|
||||
assert.containsN(target, '.o_searchview_autocomplete li', 2,
|
||||
"there should be 2 result for 'a' in search bar autocomplete");
|
||||
|
||||
await testUtils.dom.triggerEvent(searchInput, 'keydown', {key: 'Enter'});
|
||||
assert.strictEqual(target.querySelector('.o_searchview_input_container .o_facet_values').innerText.trim(),
|
||||
"a", "There should be a field facet with label 'a'");
|
||||
});
|
||||
|
||||
QUnit.test('select an autocomplete field with `context` key', async function (assert) {
|
||||
assert.expect(9);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user