From 9f33ddd883eebfc32c7e6cac638f705ea3e9a26b Mon Sep 17 00:00:00 2001 From: Sli Date: Thu, 9 Jan 2025 01:04:11 +0100 Subject: [PATCH] Fix inconsistent search behavior on counter click codes --- .../counter/components/counter-product-select-index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/counter/static/bundled/counter/components/counter-product-select-index.ts b/counter/static/bundled/counter/components/counter-product-select-index.ts index 75a2a4e5..6484385e 100644 --- a/counter/static/bundled/counter/components/counter-product-select-index.ts +++ b/counter/static/bundled/counter/components/counter-product-select-index.ts @@ -76,7 +76,15 @@ export class CounterProductSelect extends AutoCompleteSelectBase { return { ...super.tomSelectSettings(), openOnFocus: false, - searchField: ["code", "text"], + // We make searching on exact code matching a higher priority + // We need to manually set weights or it results on an inconsistent + // behavior between production and development environment + searchField: [ + // @ts-ignore documentation says it's fine, specified type is wrong + { field: "code", weight: 2 }, + // @ts-ignore documentation says it's fine, specified type is wrong + { field: "text", weight: 0.5 }, + ], }; } }