From dadfb66aa9aa53f6b8ce61ab9ff648bdc065ae89 Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Fri, 5 Jun 2026 22:20:15 +0700 Subject: [PATCH] feat: prevent partial selection of combo items by toggling entire combo groups in SplitBillScreen --- .../split_bill_screen_patch.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/static/src/app/screens/split_bill_screen/split_bill_screen_patch.js b/static/src/app/screens/split_bill_screen/split_bill_screen_patch.js index 1b1ea84..896326c 100644 --- a/static/src/app/screens/split_bill_screen/split_bill_screen_patch.js +++ b/static/src/app/screens/split_bill_screen/split_bill_screen_patch.js @@ -5,9 +5,36 @@ import { patch } from "@web/core/utils/patch"; patch(SplitBillScreen.prototype, { onClickLine(line) { + // Block clicking on combo sub-items directly. + // The parent line handles the entire combo group selection. if (line.combo_parent_id) { return; } + + // For combo parent lines, toggle all lines in the combo group at once. + // This prevents partial selection of combo sub-items. + if (line.combo_line_ids && line.combo_line_ids.length > 0) { + const allLines = line.getAllLinesInCombo(); + + // Determine current state: are ALL lines already at their max qty? + const allAtMax = allLines.every( + (l) => (this.qtyTracker[l.uuid] || 0) === l.getQuantity() + ); + + for (const l of allLines) { + const uuid = l.uuid; + const maxQty = l.getQuantity(); + + // Toggle: if all are at max -> reset to 0; otherwise -> set to max + this.qtyTracker[uuid] = allAtMax ? 0 : maxQty; + this.priceTracker[uuid] = + (l.prices.total_included / l.qty) * this.qtyTracker[uuid]; + this.setLineQtyStr(l); + } + return; + } + + // For regular (non-combo) lines, use default behavior. super.onClickLine(line); } });