Fix gridview error when removing the last Noble.Menu item - #94
Open
ericlewis wants to merge 2 commits into
Open
Conversation
Noble.Menu:removeItem() called setNumberOfRows() unconditionally, passing 0 when the menu was emptied, which caused "ERROR: playdate.ui.gridview sections must contain at least one row." on the console. The row count is now only updated when at least one item remains; emptying the menu instead resets the selection state (currentItemName is cleared and currentItemNumber returns to 1, matching a freshly created menu), and draw() early-returns for an empty menu so the retained one-row gridview never draws a phantom cell. Repopulating an emptied menu via addItem() resizes the gridview as usual. Fixes upstream issue NobleRobot#89. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Commit 58ee1e9 fixed the gridview crash when removing the last menu item by clearing currentItemName. However, addItem() never repaired the selection: an item added to an emptied menu drew as selected (the gridview still had a selected row), but click() silently did nothing because clickHandlers[currentItemName] looked up a nil key, until the player first pressed up or down. After setting the row count, addItem() now assigns the first item as the current item whenever there is none, and re-selects row 1 if the menu is active. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
✅ Deploy Preview for cheery-choux-736619 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #89.
Noble.Menu:removeItem()calledsetNumberOfRows()unconditionally, passing 0 when the menu was emptied, which triggersERROR: playdate.ui.gridview sections must contain at least one rowon the console.Two commits:
removeItem(): the row count is now only updated when at least one item remains. Emptying the menu instead resets the selection state (currentItemNameis cleared andcurrentItemNumberreturns to 1, matching a freshly created menu), anddraw()early-returns for an empty menu so the retained one-row gridview never draws a phantom cell. Repopulating an emptied menu viaaddItem()resizes the gridview as usual.addItem(): an item added to an emptied menu is now made the current item. Without this, the first item added back drew as selected (the gridview still had a selected row), butclick()silently did nothing —clickHandlers[currentItemName]looked up a nil key — until the player first pressed up or down.🤖 Generated with Claude Code