-
-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array size limited when using toga.Selection #2319
Comments
To clarify - are you seeing this on macOS, or iOS, or both? The report says iOS, but the screenshot is of |
Oops! Mac |
Thanks - I've found the source of the problem. I'm not sure if this is bug in error handling or in the widget itself; at the very least, error handling should be improved. The bug is entirely macOS specific; AFAICT, no other backend is affected. The problem is with your data - it contains duplicates. There are 2 "a" entries and 2 "b" entries; the bug you're seeing is cause because the list of unique entries has less items than the list of entries. On macOS, Selection items are expected to be unique. When macOS encounters the first duplicate, it repositions the first original item to the end of the list; but at this point, the number of items in the data doesn't match the number of items in the selection, so the insertion of the second item fails because it exceeds the current size of the selection. The immediate workaround - avoid duplicate titles in your selection data. Longer term, I can see 2 possible fixes:
All the other backends allow duplicate titles, which suggests that (2) is the fix required for macOS. This SO post suggests a possible approach. However, it's worth noting that allowing duplicated entries means you end up with selections with duplicated titles that can't be differentiated. At the very least, this should probably be raised as a warning, as it indicates a possible UX issue. For future reference, the part of this bug report that was helpful was the code sample included in the screenshot. The first part of any bug triage process is reproducing the bug; and that means having a working example. If you hadn't provided the screenshot of your code, I would have concluded this bug didn't exist, because the |
This is exactly the problem I was having in the three places I received the error. Was able to add an '*' or number to solve the problem for now. Thank you! |
Side note - it's a lot easier to share text as text, rather than screenshots. You can copy code from your editor directly into the Github window, and it will be rendered as code if you include it in triple backticks:
As for changing the representation to be unambiguous - that's definitely possible. The literal text in the selection items doesn't need to match the actual "value" represented by the selection. There's 2 possible approaches to implementing this. Instead of specifying the items as a list of strings, use:
|
Great info here- thank you! |
Describe the bug
When creating an array, and setting said array as the items in toga.Selection, size is limited to 27 selections (specifically on iOS) before error occurs.
Steps to reproduce
2024-01-03 16:53:10.906 python[65170:960463] *** Assertion failure in -[NSMenu insertItemWithTitle:action:keyEquivalent:atIndex:], NSMenu.m:1185
Expected behavior
Expect toga.Selection to show all items in array if larger than 27.
Screenshots
Environment
Logs
No logs available from this error.
Additional context
No response
The text was updated successfully, but these errors were encountered: