-
Notifications
You must be signed in to change notification settings - Fork 949
Allow selected_index=none
in selection container widgets
#1495
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
Merged
jasongrout
merged 24 commits into
jupyter-widgets:master
from
pbugnion:selection-container-allow-none
Jul 15, 2017
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
0376350
Allow none in accordion widget
pbugnion 9b371aa
Allow none in tab panel
pbugnion b6ec556
Add framework for current selection unit tests
pbugnion 1f77604
Test signal triggered correctly
pbugnion f481d54
Test for setting by value
pbugnion 52d8e26
Test for setting index and values to wrong values
pbugnion 98e48b6
Unittest for inserting an item in selection
pbugnion 88e4182
Test for adjusting selection after items moved
pbugnion 1a4a019
Test for adjusting selection after moving item
pbugnion 465c1dd
Test for clearing selection
pbugnion a184d23
Tests for changing the item selected
pbugnion 89238bb
Use ArrayExt.insert instead of splice.
pbugnion 8bd2304
Actually modify items in place
pbugnion e170bb2
Tests for removing an item
pbugnion 04c10b0
Long line fix
pbugnion eac8ae4
Validate that selected index is not out of bounds
pbugnion e5b298c
Appropriate file header
pbugnion 59fcdb4
Update documentation for Tabs and Accordions
pbugnion 88ba725
Explain selected_index traitlet
pbugnion c31ac16
fix typo
jasongrout a2af8b5
We don't allow an index out of range now, so update docs.
jasongrout cc0d435
Code style
jasongrout 34dd60a
Translate from phosphor convention of -1 being no selection
jasongrout 95cc187
Fix js comment
jasongrout File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
from unittest import TestCase | ||
|
||
from traitlets import TraitError | ||
|
||
from ipywidgets.widgets import Accordion, HTML | ||
|
||
|
||
class TestAccordion(TestCase): | ||
|
||
def setUp(self): | ||
self.children = [HTML('0'), HTML('1')] | ||
|
||
def test_selected_index_none(self): | ||
accordion = Accordion(self.children, selected_index=None) | ||
state = accordion.get_state() | ||
assert state['selected_index'] is None | ||
|
||
def test_selected_index(self): | ||
accordion = Accordion(self.children, selected_index=1) | ||
state = accordion.get_state() | ||
assert state['selected_index'] == 1 | ||
|
||
def test_selected_index_out_of_bounds(self): | ||
with self.assertRaises(TraitError): | ||
Accordion(self.children, selected_index=-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.