Fix music library paths not auto-saving on settings page
Dynamic music path inputs were created after auto-save listeners were attached, so typing in them never triggered a save. Now attaches change listeners when creating or rendering path rows. Removing a path also triggers auto-save immediately.
This commit is contained in:
parent
d77274c2ea
commit
d44c78c87b
1 changed files with 16 additions and 3 deletions
|
|
@ -6704,9 +6704,13 @@ function renderMusicPaths(paths) {
|
|||
container.innerHTML = paths.map((p, i) => `
|
||||
<div class="form-group music-path-row" style="margin-bottom: 4px;">
|
||||
<input type="text" class="music-path-input" value="${escapeHtml(p)}" placeholder="/music or C:\\Music" style="flex:1;">
|
||||
<button class="test-button" onclick="this.closest('.music-path-row').remove()" style="padding: 8px 12px; color: #ef5350; border-color: rgba(239,83,80,0.3);">×</button>
|
||||
<button class="test-button" onclick="_removeMusicPathRow(this)" style="padding: 8px 12px; color: #ef5350; border-color: rgba(239,83,80,0.3);">×</button>
|
||||
</div>
|
||||
`).join('');
|
||||
// Attach auto-save to dynamically rendered inputs
|
||||
container.querySelectorAll('.music-path-input').forEach(input => {
|
||||
input.addEventListener('change', () => { if (typeof debouncedAutoSaveSettings === 'function') debouncedAutoSaveSettings(); });
|
||||
});
|
||||
}
|
||||
|
||||
function addMusicPathRow() {
|
||||
|
|
@ -6720,10 +6724,19 @@ function addMusicPathRow() {
|
|||
row.style.marginBottom = '4px';
|
||||
row.innerHTML = `
|
||||
<input type="text" class="music-path-input" value="" placeholder="/music or C:\\Music" style="flex:1;">
|
||||
<button class="test-button" onclick="this.closest('.music-path-row').remove()" style="padding: 8px 12px; color: #ef5350; border-color: rgba(239,83,80,0.3);">×</button>
|
||||
<button class="test-button" onclick="_removeMusicPathRow(this)" style="padding: 8px 12px; color: #ef5350; border-color: rgba(239,83,80,0.3);">×</button>
|
||||
`;
|
||||
container.appendChild(row);
|
||||
row.querySelector('input').focus();
|
||||
const input = row.querySelector('input');
|
||||
input.focus();
|
||||
// Auto-save when the user finishes typing a path
|
||||
input.addEventListener('change', () => { if (typeof debouncedAutoSaveSettings === 'function') debouncedAutoSaveSettings(); });
|
||||
}
|
||||
|
||||
function _removeMusicPathRow(btn) {
|
||||
btn.closest('.music-path-row').remove();
|
||||
// Auto-save after removing a path
|
||||
if (typeof debouncedAutoSaveSettings === 'function') debouncedAutoSaveSettings();
|
||||
}
|
||||
|
||||
function collectMusicPaths() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue