-
Notifications
You must be signed in to change notification settings - Fork 12
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
ComboBox: factor out classes for subcomponents #430
Comments
@ariel-phet Permission to work on this? It may be a multi-day project. |
@pixelzoom permission granted... ComboBox is used so much that having it in good shape seems very worthwhile for the project as whole. |
I think it might also be worthwhile to formalize "combo box list" by making it a class. It's currently duck typed, and that makes it difficult to document. |
Could we make a new folder in sun for ComboBox related code? If there are 5 classes I would prefer that organization to having all of them in the same file. That may help with readability too. Though it would make a need for many require statements to be refactored. |
Yep -- I'll evaluate breaking ComboBox's inner classes out into separate .js files. |
Signed-off-by: Chris Malley <[email protected]>
Signed-off-by: Chris Malley <[email protected]>
Signed-off-by: Chris Malley <[email protected]>
Signed-off-by: Chris Malley <[email protected]>
@zepumph FYI, so far I've factored out |
Signed-off-by: Chris Malley <[email protected]>
Signed-off-by: Chris Malley <[email protected]>
Signed-off-by: Chris Malley <[email protected]>
Signed-off-by: Chris Malley <[email protected]>
In light of #419, I'm rethinking the responsibilities and sharing of ComboBoxItemNode. Now I think that what should be shared by the button and list is ComboBoxItem.node, and ComboBoxItemNode should become the thing that appears in the list, supports highlighting, etc. |
Signed-off-by: Chris Malley <[email protected]>
…lickToDismissListener if click is over button, #430
In the previous commit, clicking on the button toggles the list's visibility: // Clicking on the button toggles visibility of the list
this.button.addListener( () => {
if ( !this.listBox.visible ) {
this.showList();
}
else {
this.hideList();
}
} ); And this.clickToDismissListener = {
down: event => {
//TODO sun#430 is Trail.nodes public? Is there a better way to determine if we clicked over this.button?
// Ignore if we click over the button, since the button will handle hiding the list.
if ( event.trail.nodes.indexOf( this.button ) === -1 ) {
this.hideList();
}
}
}; This seems to do the job. But see the TODO above. /**
* Does this Trail contain the specified Node?
* @param {Node} node
*/
containsNode( node ) {
return event.trail.nodes.indexOf( node ) !== -1;
} |
That is right, because the button's listener is called on |
If |
Signed-off-by: Chris Malley <[email protected]>
Signed-off-by: Chris Malley <[email protected]>
Blocked by phetsims/scenery#927. |
I see that other sims are accessing @jessegreenberg regarding your feedback in #430 (comment)... (1) is being addressed by #452. (2) has been addressed as described in #430 (comment). Anything else to do here? If not, feel free to close this issue. |
OK, thanks for going through #452. I tested #430 (comment), it looks good and works good. I am going to remove this TODO now:
Closing. |
Thanks for the review @jessegreenberg. FYI, I added this TODO where you removed the sun#430 TODO:
|
Signed-off-by: Chris Malley <[email protected]>
Signed-off-by: Chris Malley <[email protected]>
ComboBox's list is currently just a Rectangle, and all of the responsibilities related to the list are spread out across ComboBox's constructor and methods. Creating a
ListNode
inner class to handle list responsibilities would go a long ways towards cleaning up the PhET-iO (#405) and a11y (#314) instrumentation.The text was updated successfully, but these errors were encountered: