fix: resolve off-by-one in ModeWidget._clear() keeping tonic active#7218
fix: resolve off-by-one in ModeWidget._clear() keeping tonic active#7218rakshaak29 wants to merge 1 commit into
Conversation
|
🧪 Jest Test Results ❌ Some Jest tests failed. Please check the logs and fix the issues before merging. Coverage: Statements: 45.18% | Branches: 36.53% | Functions: 50.56% | Lines: 45.62% Note: These failures may be introduced by this PR or may already exist in the master branch. Failed Tests: |
|
This pull request has been open for more than 60 days without any activity. It will be closed in 3 days unless the |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7218 +/- ##
=======================================
Coverage 59.27% 59.27%
=======================================
Files 176 176
Lines 57975 57975
=======================================
Hits 34365 34365
Misses 23610 23610 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
fb2f52a to
1c78c3b
Compare
Description
This PR resolves a critical off-by-one bug in the Mode Widget where the
_clear()method failed to deselect the root/tonic note (index0).Because
_selectedNotes[0]was never cleared, a cascade of silent failures occurred whenever a user attempted to clear the widget to build a new mode from scratch:_calculateMode()logic would evaluate the single note as[12], which_save()would blindly overwrite intolocalStorage.custommode, clobbering the user's legitimately saved custom modes.[12]does not match any valid entry inMUSICALMODES,_setModeName()would blank the mode label, causing the generatedactionanddefinemodeblocks to always incorrectly default to the name"custom"._rotateRight/_rotateLeft) immediately abort if_selectedNotes[0]is true, meaning rotation was permanently broken after clicking Clear.PR Category
Changes Made
js/widgets/modewidget.js: Updated the loop bounds in_clear()to initialize ati = 0instead ofi = 1, ensuring all 12 note positions are properly deselected.js/widgets/__tests__/modewidget.test.js: Updated theshould clear all notes except roottest. The test was originally written to explicitly expect this broken behavior. It has been renamed toshould clear all notes including rootand updated to assert that_selectedNotes[0]evaluates tofalse.Testing Performed
npm test. All 5,006 tests across 152 suites pass successfully.