-
Notifications
You must be signed in to change notification settings - Fork 949
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
Allow selected_index=none
in selection container widgets
#1495
Allow selected_index=none
in selection container widgets
#1495
Conversation
f3806bc
to
b6ec556
Compare
selected_index=none
in selection container widgetsselected_index=none
in selection container widgets
7494306
to
88ba725
Compare
@@ -130,7 +130,7 @@ class TabPanel extends Widget { | |||
* Set the index of the currently selected tab. | |||
* | |||
* #### Notes | |||
* If the index is out of range, it will be set to `-1`. | |||
* If the index is out of range, it will be set to `null`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the logic here is still missing for out of range values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, you don't need to do anything here - the tab bar handles the logic to set its current index to -1 if out of range. We'll just handle the translation to null up where we retrieve the index.
@@ -120,7 +120,7 @@ class TabPanel extends Widget { | |||
* Get the index of the currently selected tab. | |||
* | |||
* #### Notes | |||
* This will be `-1` if no tab is selected. | |||
* This will be `null` if no tab is selected. | |||
*/ | |||
get currentIndex(): number { | |||
return this.tabBar.currentIndex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic needs to be added here to return null if the tab bar index is -1.
Thanks! |
Prior to this commit, the way to unset the selection for a tab or accordion widget was to set
selected_index = -1
. Having to set it toNone
would be better (see issue #1493 ).This PR allows setting the index to None. The bulk of the changes are in the
Selection
class, which now allows setting the index to null.This is what's left to do:This is now ready for review.