KCarlile / guitar-diagrams-js

Open source JavaScript library for drawing guitar chords and scales on an HTML5 canvas.
https://demo.kcarlile.com/guitar-diagrams-js/
GNU General Public License v3.0
0 stars 0 forks source link

String names flip ordering when toggling orientation via button #42

Closed KCarlile closed 2 months ago

KCarlile commented 2 months ago

Background

Toggling the orientation button results in the string names reversing under some circumstances. Toggle back and forth to see this bug appear. This happens on the examples page and the testing page.

image image image image

Acceptance Criteria

Approach

Notes

This is related to #36

KCarlile commented 2 months ago

The array.reverse() function returns a reversed array, but it also mutates the original array. This was causing the this.#config.stringNames to be reversed unexpectedly. Using the deep copy method to clone the array solved the issue: let stringNames = [...this.#config.stringNames]; // deep copy array

KCarlile commented 2 months ago

PR into develop: #47