Skip to content

Fix gridview error when removing the last Noble.Menu item - #94

Open
ericlewis wants to merge 2 commits into
NobleRobot:mainfrom
ericlewis:fix/menu-remove-last-item
Open

Fix gridview error when removing the last Noble.Menu item#94
ericlewis wants to merge 2 commits into
NobleRobot:mainfrom
ericlewis:fix/menu-remove-last-item

Conversation

@ericlewis

Copy link
Copy Markdown

Fixes #89.

Noble.Menu:removeItem() called setNumberOfRows() unconditionally, passing 0 when the menu was emptied, which triggers ERROR: playdate.ui.gridview sections must contain at least one row on the console.

Two commits:

  1. removeItem(): 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.

  2. 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), but click() silently did nothing — clickHandlers[currentItemName] looked up a nil key — until the player first pressed up or down.

🤖 Generated with Claude Code

ericlewis and others added 2 commits August 11, 2026 05:57
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>
@netlify

netlify Bot commented Aug 11, 2026

Copy link
Copy Markdown

Deploy Preview for cheery-choux-736619 ready!

Name Link
🔨 Latest commit 5941c9a
🔍 Latest deploy log https://app.netlify.com/projects/cheery-choux-736619/deploys/6a7af30784333a00080abf91
😎 Deploy Preview https://deploy-preview-94--cheery-choux-736619.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ERROR: playdate.ui.gridview sections must contain at least one row when removing last Noble.Menu item

1 participant