question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Menu] Entire App crashes if no MenuItems exist

See original GitHub issue

Describe the bug When selecting the Menu and no items are rendered, the entire app crashes

Screenshot 2019-12-26 at 2 52 26 PM Screenshot 2019-12-26 at 2 53 03 PM

Expected Behavior Dropdown should not open (since no items) and definitely not crash the app

To Reproduce https://codesandbox.io/s/great-volhard-ozr5l

Suggested solution(s)

I can make the PR, let me know which way is best

Desktop (please complete the following information):

  • OS - MacOS Catalina
  • Browser - Chrome
  • Version (“@chakra-ui/core”: “^0.5.2”)

Additional context Usually the MenuList component would have children (MenuItem), in the event where the list is populated by data from an api and the server is down, the app should still work, with data that is stored locally. In the example below, the menu is usually populated with a list of schools to choose from, however since the server is down, the list would be empty.

<MenuList placement="bottom-start">
  {schools.map(a => (
    <MenuItem
      fontSize="sm"
      key={a.id}
      onClick={() => selectSchool(a.id)}
    >
      {a.name}
    </MenuItem>
  ))}
</MenuList>

Kapture 2019-12-26 at 14 57 02

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
segunadebayocommented, Feb 26, 2020

Hi @iRoachie, I’ve just fixed this bug. Ideally, you might not want to render the MenuList if schools array is empty.

I’ll release a patch shortly for this.

0reactions
iRoachiecommented, Feb 26, 2020

Thanks, that’s what I ended up doing

Read more comments on GitHub >

github_iconTop Results From Across the Web

android option menu crashes - Stack Overflow
When I click on the menu, the 2 points "About" and "Help" appears. But when I click on one of these entries, the...
Read more >
Working with the AppBar - Android Developers
The top app bar provides a consistent place along the top of your app window for displaying information and actions from the current...
Read more >
If an app freezes or quits unexpectedly on Mac - Apple Support
Choose Apple menu > Force Quit, select the app in the dialog that appears, then click Force Quit. If the app quit, reopen...
Read more >
Onclick Listener Crashes app (Example) - Treehouse
Every time i add the onclick listener code shown in the video the app crashes when I try to run it. there is...
Read more >
bizarre OutOfBoundsException on Menuitem.Remove only on ...
Works fine on Mac, throws an OutOfBoundsException on Windows, when j= 0. ... am trying to tell you that a test app containing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found