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 <noreply@anthropic.com>
This commit is contained in:
@@ -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<StockItem>();
|
||||
}
|
||||
|
||||
private async Task SaveStockFromInventoryAsync()
|
||||
{
|
||||
stockErrorMessage = null;
|
||||
|
||||
Reference in New Issue
Block a user