From 0c5ecf716a39b74e5378606493ddfec31287c62f Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Sat, 1 Aug 2026 19:23:49 -0400 Subject: [PATCH] fix: prefill Stock Length dropdown when editing inventory-sourced stock Editing an inventory-sourced job stock row opened the Edit Stock modal with the Stock Length dropdown blank instead of showing the row's current length. EditStock() correctly set newStock.StockItemId from the row, but then called the fire-and-forget OnStockMaterialChanged(), which (a) unconditionally reset StockItemId to null, and (b) never triggered a re-render since its Task wasn't awaited by the event handler pipeline. Made EditStock async and await a dedicated loader that populates availableStockItems without touching StockItemId, so Blazor re-renders once the candidate lengths arrive. Found during Task 2 manual verification of the unified Add Stock modal (Step 6). Co-Authored-By: Claude Sonnet 5 --- CutList.Web/Components/Pages/Jobs/Edit.razor | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CutList.Web/Components/Pages/Jobs/Edit.razor b/CutList.Web/Components/Pages/Jobs/Edit.razor index 6011c31..bea84a5 100644 --- a/CutList.Web/Components/Pages/Jobs/Edit.razor +++ b/CutList.Web/Components/Pages/Jobs/Edit.razor @@ -1278,7 +1278,7 @@ else } } - private void EditStock(JobStock stock) + private async Task EditStock(JobStock stock) { editingStock = stock; newStock = new JobStock @@ -1301,10 +1301,20 @@ else if (!stock.IsCustomLength) { - _ = OnStockMaterialChanged(); + // Load the candidate stock lengths without going through OnStockMaterialChanged, + // which would reset newStock.StockItemId and blank the prefilled selection. + // Awaited (not fire-and-forget) so Blazor re-renders once the list arrives. + await LoadAvailableStockItemsAsync(stock.MaterialId); } } + private async Task LoadAvailableStockItemsAsync(int materialId) + { + availableStockItems = materialId > 0 + ? await JobService.GetAvailableStockForMaterialAsync(materialId) + : new List(); + } + private async Task SaveStockFromInventoryAsync() { stockErrorMessage = null;