fix(inventory): preserve form state across re-renders
Fixes bug where expanding an existing storage location would close the "Add Location" form that was currently open. This happened because renderInventory() recreated all HTML from scratch, resetting all inline forms to hidden state. Solution: - Track open form states in inventoryActions module - Restore form visibility after each re-render - Applies to all inline forms: add location, add items (on person, stored, assets) This also fixes the related issue where switching tabs would close open forms. Fixes: Location disappears when expanding while adding new location
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { extensionSettings, $inventoryContainer } from '../../core/state.js';
|
||||
import { getInventoryRenderOptions } from '../interaction/inventoryActions.js';
|
||||
import { getInventoryRenderOptions, restoreFormStates } from '../interaction/inventoryActions.js';
|
||||
import { parseItems } from '../../utils/itemParser.js';
|
||||
|
||||
// Type imports
|
||||
@@ -425,6 +425,9 @@ export function updateInventoryDisplay(containerId, options = {}) {
|
||||
const inventory = extensionSettings.userStats.inventory;
|
||||
const html = generateInventoryHTML(inventory, options);
|
||||
container.innerHTML = html;
|
||||
|
||||
// Restore form states after re-rendering
|
||||
restoreFormStates();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -447,6 +450,9 @@ export function renderInventory() {
|
||||
// Generate HTML and update DOM
|
||||
const html = generateInventoryHTML(inventory, options);
|
||||
$inventoryContainer.html(html);
|
||||
|
||||
// Restore form states after re-rendering (fixes Bug #1)
|
||||
restoreFormStates();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user