fix: chord actions not sorted

This commit is contained in:
2023-11-18 15:53:07 +01:00
parent 683561dc06
commit e84470d577
3 changed files with 10 additions and 3 deletions

View File

View File

@@ -29,12 +29,16 @@
if (!editing) return if (!editing) return
editing = false editing = false
if (pressedKeys.size < 2) return if (pressedKeys.size < 2) return
if (!chord) return dispatch("submit", [...pressedKeys].sort()) if (!chord)
return dispatch(
"submit",
[...pressedKeys].sort((a, b) => a - b),
)
changes.update(changes => { changes.update(changes => {
changes.push({ changes.push({
type: ChangeType.Chord, type: ChangeType.Chord,
id: chord!.id, id: chord!.id,
actions: [...pressedKeys].sort(), actions: [...pressedKeys].sort((a, b) => a - b),
phrase: chord!.phrase, phrase: chord!.phrase,
}) })
return changes return changes
@@ -54,7 +58,10 @@
{:else if !editing && !chord} {:else if !editing && !chord}
<span>{$LL.configure.chords.NEW_CHORD()}</span> <span>{$LL.configure.chords.NEW_CHORD()}</span>
{/if} {/if}
<ActionString display="keys" actions={editing ? [...pressedKeys].sort() : chord?.actions ?? []} /> <ActionString
display="keys"
actions={editing ? [...pressedKeys].sort((a, b) => a - b) : chord?.actions ?? []}
/>
<sup></sup> <sup></sup>
</button> </button>

View File