alexguirre / RAGENativeUI

MIT License
117 stars 37 forks source link

`UIMenu.RemoveItemAt` with only 1 item in the menu throws `DivideByZeroException` #160

Open alexguirre opened 1 year ago

alexguirre commented 1 year ago

Probably the issue is in this line that doesn't check for Items.Count == 0: https://github.com/alexguirre/RAGENativeUI/blob/7a9066455a96638a9845bbd87b51467c68d58996/Source/ScrollableListBase.cs#L211

Rohit685 commented 1 year ago

Workaround to the bug: Using the Clear() function to delete item when the MenuItems count is equal to 1

It would look something along the lines of:

 if (DeleteLocationMenu.MenuItems.Count == 1)
                {
                    DeleteLocationMenu.Clear();
                }
                else
                {
                    DeleteLocationMenu.RemoveItemAt(index);
                }