From dfc714ff3d304c8ebcf3bab5796e13a0b01e68f8 Mon Sep 17 00:00:00 2001 From: Sli Date: Fri, 28 Aug 2026 15:04:01 +0200 Subject: [PATCH] Fix broken ProductAjaxSelect widget --- .../bundled/counter/components/ajax-select-index.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/counter/static/bundled/counter/components/ajax-select-index.ts b/counter/static/bundled/counter/components/ajax-select-index.ts index e76970fe..85b8238d 100644 --- a/counter/static/bundled/counter/components/ajax-select-index.ts +++ b/counter/static/bundled/counter/components/ajax-select-index.ts @@ -28,18 +28,23 @@ export class ProductAjaxSelect extends AjaxSelect { return []; } - private getName(item: SimpleProductSchema, sanitize: typeof escape_html): string { + // In the context in which this method is called, `this` might be shadowed + // We need to call it explicitly from the class itself + private static getName( + item: SimpleProductSchema, + sanitize: typeof escape_html, + ): string { return item.code ? `${sanitize(item.code)} - ${sanitize(item.name)}` : item.name; } protected renderOption(item: SimpleProductSchema, sanitize: typeof escape_html) { return `
- ${this.getName(item, sanitize)} + ${ProductAjaxSelect.getName(item, sanitize)}
`; } protected renderItem(item: SimpleProductSchema, sanitize: typeof escape_html) { - return `${this.getName(item, sanitize)}`; + return `${ProductAjaxSelect.getName(item, sanitize)}`; } }