Fix regressions in MusicKeyboard widget #2863
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After #2849, the Music Keyboard widget has two regressions:
The lower 8 notes from G4 to C4) in the column of the grid were unclickable.
This is happening as the
for
loop (starting from line 1057 in themakeClickable
function), the parameterthis.layout.length
is getting set to 5, after Multiple Bug Fixes and Enhancements to Music Keyboard #2849, instead of 12. Now, the error arises in the_keysLayout
function where the notes are pushed in the layout array. So,sortedList
is replaced bynewList
. Here,newList = fillChromaticGaps(sortedNotesList)
Thus,
newList
contains all the 12 notes whereassortedList
contains only the first 5 notes.In case when multiple notes were selected in a column, the music would stop playing and not move any further.
This regression arises as when multiple notes are selected, the
playOne
could not fetch theobjId
of the notes fromselectedNotes
. Now, this happens when thesetNoteCell
method is called in thesetNotes
function. In thissetNoteCell
method, when the note is being pushed in theselectedNotes
array,objId
should be assigned to that in thedisplayLayout
(introduced in Multiple Bug Fixes and Enhancements to Music Keyboard #2849) array and not of thelayout
array.Below is the video showing both these regressions:
mk.3.mp4
This patch fixes these regressions and the widget functions as expected.
mk.1.mp4
Please have a look at this @walterbender @meganindya and let me know if it has any issues.
Thanks.