tirando pattern padrão quando não estamos editando alguma

This commit is contained in:
JotaChina committed 2025-12-27 21:14:05 -03:00
1 parent a985798206
commit d3e209d8e8
3 files changed
+38 -28

No files matched your search

+12 -15
View File
@@ -348,7 +348,7 @@ export function updateGlobalPatternSelector() {
const isFocused = !!appState.pattern.focusedBasslineId;
// track de referência que tenha patterns
// qualquer instrumento serve como referência de nomes/quantidade de patterns
const referenceTrack = (appState.pattern.tracks || []).find(
(t) => t.type !== "bassline" && Array.isArray(t.patterns) && t.patterns.length > 0
);
@@ -363,16 +363,12 @@ export function updateGlobalPatternSelector() {
return;
}
const hasSelection = Number.isInteger(appState.pattern.activePatternIndex);
// ✅ placeholder só quando NÃO está focado e NÃO tem seleção
if (!isFocused && !hasSelection) {
const ph = document.createElement("option");
ph.value = "";
ph.textContent = "Selecione uma pattern";
ph.disabled = true;
ph.selected = true;
sel.appendChild(ph);
// ✅ fora do foco: permite "limpar seleção"
if (!isFocused) {
const noneOpt = document.createElement("option");
noneOpt.value = "";
noneOpt.textContent = "Selecione uma pattern";
sel.appendChild(noneOpt);
}
referenceTrack.patterns.forEach((p, idx) => {
@@ -382,13 +378,14 @@ export function updateGlobalPatternSelector() {
sel.appendChild(opt);
});
// Define seleção atual
const idx = appState.pattern.activePatternIndex;
if (isFocused) {
// em foco: se não tiver índice ainda, cai pra 0
sel.value = String(appState.pattern.activePatternIndex ?? 0);
sel.value = String(Number.isInteger(idx) ? idx : 0);
} else {
// fora de foco: só seta valor se realmente existir seleção
sel.value = hasSelection ? String(appState.pattern.activePatternIndex) : "";
sel.value = Number.isInteger(idx) ? String(idx) : "";
}
sel.disabled = false;
}