fix: prevent instant plans from breaking after customization

Fixed multiple issues:
1. Enhanced closeInstantCustomization to properly reset state
2. Clear customization containers and config state
3. Re-render instant servers when returning from customize
4. Fixed tab switching to preserve instant server selection
5. Auto-select first instant server when switching back to instant tab

Now instant plans work correctly:
- After customizing, clicking back returns to instant grid
- Switching tabs preserves instant server functionality
- Selected server state is properly maintained

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2025-12-06 01:39:37 +04:00
Unverified
parent 95e4ad85ac
commit 29f2fa4703

View File

@@ -4122,7 +4122,27 @@ var wpcf7 = {
isInstantCustomized = false;
document.getElementById('instantOptions').style.display = 'none';
document.getElementById('instantServersGrid').style.display = 'grid';
// Clear the customization container to avoid conflicts
const instantContainer = document.getElementById('instantDynamicConfigContainer');
if (instantContainer) instantContainer.innerHTML = '';
// Reset config state to clean values
configState = {};
configIds = {};
storageSelection = {};
// Clear any original drives tracking
if (window.originalDrives) {
window.originalDrives = [];
}
// Re-render the instant servers grid to ensure proper display
renderInstantServers();
// Update summary and specs for the selected instant server
updateSummary();
updateSpecs(selectedServer);
}
// Customize Instant Server Button Logic
@@ -5332,8 +5352,32 @@ var wpcf7 = {
document.getElementById('instant-content').classList.toggle('active', currentTab === 'instant');
document.getElementById('custom-content').classList.toggle('active', currentTab === 'custom');
selectedServer = null;
// Reset customization state when switching
isInstantCustomized = false;
document.getElementById('instantOptions').style.display = 'none';
document.getElementById('instantServersGrid').style.display = 'grid';
document.getElementById('customOptions').style.display = 'none';
// Clear containers
const instantContainer = document.getElementById('instantDynamicConfigContainer');
if (instantContainer) instantContainer.innerHTML = '';
// Reset config state
configState = {};
configIds = {};
storageSelection = {};
// If switching back to instant tab, re-render instant servers
if (currentTab === 'instant') {
renderInstantServers();
// Auto-select first instant server if none selected
if (!selectedServer && instantServers.length > 0) {
selectInstantServer(instantServers[0].id);
}
} else {
selectedServer = null;
}
updateSummary();
});
});