Skip to content
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

Bug fix for toga.Selection on android for value #1914

Merged

Conversation

LunaMeadows
Copy link
Contributor

@LunaMeadows LunaMeadows commented Apr 29, 2023

Added an if statement for get_selected_item that checks if the Selection has values or not. If it does not it will return None which is consistent with linux and windows. If it has values, it will return "" with type str if an empty value is selected.

Makes the return value consistent across platforms

Fixes #1723

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. In this case, I think Android may have been the one instance doing it right - the issue is with the other platforms :-) I've pushed an update to the selection example that provides a demonstration case; returning None when there isn't anything to select seems like the right outcome, rather than "" which could be ambiguous with a legitimate (albeit ill-advised) actual list entry with no label.

On that basis, I've fixed the cocoa and iOS implementations as well; if you want to try a winforms and/or GTK fix before I get to it tomorrow morning my time (~12 hours from now), feel free.

@LunaMeadows
Copy link
Contributor Author

I can take care of the GTK platform. My windows machine is still out of service right now.

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the Winforms and GTK implementations are already doing the right thing, so I think this is good to go! Thanks for doing the initial investigation on this.

@freakboy3742 freakboy3742 merged commit 7b1d586 into beeware:main May 3, 2023
43 checks passed
@LunaMeadows LunaMeadows deleted the android_selection_value_None_#1723 branch May 3, 2023 05:43
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.

Inconsistent behaviour with toga.Selection value attribute between Windows and Android
2 participants