This repository was archived by the owner on Aug 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Disabled Bellows should prevent close behaviour #56
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2403454
Disabling Bellows should also prevent open Bellows' items from closing
7ac98db
Add a test for trying to close disabled open items
c201449
Added helper methods for determining an item's open and disabled states
cff793d
Removed the setTimeout in the test. We don't need this because we're …
bd82156
Bump version number
39ebbde
Updating changelog
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,4 @@ | ||
| <div class="bellows__item bellows--is-disabled bellows--is-open"> | ||
| <div class="bellows__header">Header</div> | ||
| <div class="bellows__content">Content</div> | ||
| </div> |
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 |
|---|---|---|
|
|
@@ -3,8 +3,9 @@ define([ | |
| 'text!fixtures/bellows.html', | ||
| 'text!fixtures/items.html', | ||
| 'text!fixtures/item.html', | ||
| 'text!fixtures/disableditem.html' | ||
| ], function(testSandbox, fixture, items, item, disabledItem) { | ||
| 'text!fixtures/disableditem.html', | ||
| 'text!fixtures/open-disabled-item.html' | ||
| ], function(testSandbox, fixture, items, item, disabledItem, openDisabledItem) { | ||
| var Bellows; | ||
| var $element; | ||
| var $; | ||
|
|
@@ -180,7 +181,7 @@ define([ | |
| }, | ||
| closed: function(e, ui) { | ||
| closeCount++; | ||
|
|
||
| if (closeCount === 2) { | ||
| expect($element.find('.bellows__item:not(.bellows--is-open)')).to.have.length(2); | ||
| done(); | ||
|
|
@@ -268,6 +269,24 @@ define([ | |
| done(); | ||
| }); | ||
| }); | ||
|
|
||
| it('does not close item when header clicked', function(done) { | ||
| $element.bellows(); | ||
|
|
||
| var $openDisabledItem = $(openDisabledItem); | ||
|
|
||
| $element.bellows('add', $openDisabledItem); | ||
|
|
||
| $openDisabledItem | ||
| .find('.bellows__header') | ||
| .trigger('click'); | ||
|
|
||
| setTimeout(function() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the setTimeout for?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @scalvert I was copying the test structure of MQ's test above it. Most likely reason why MQ had it in his test was to re-queue execution (which I doubt is necessary) or if the tests fails, to allow for Bellows' animation. TL:DR; It was like that when I got here. :P |
||
| expect($openDisabledItem.hasClass('bellows--is-disabled')).to.be.true; | ||
| expect($openDisabledItem.hasClass('bellows--is-open')).to.be.true; | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
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.
I wonder if now we should have an
_isOpenfunction to encapsulate this?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.
A good option if there's any more usage for it, but at the moment I think the logic is trivial enough to not need any more abstraction.
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.
So I don't feel like it's abstraction, but rather will provide better readability. We're using this same check in two places, with a ! to invert the result. I would rather see it in one place. If we had done this before, the disabled check would have automatically been applied to both without the need for this change. Get my meaning?
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.
I see your reasoning @scalvert but I don't really understand why we should encapsulate here, since a single function such as
_isOpenwon't adequately capture the logic. If we would have lumped in the disabled check with the opened check then negating both of them would be the wrong logic.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.
I do agree that in this case you can't really encapsulate this while incorporating the negation, but my guess is there's still a way. I think we want to go for readability whenever we can, and the point I'm trying to make here is that reducing conditional logic into a simple method with semantic meaning can go a long way.
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.
Totally agree.
Would something like
if (!_isOpen || _isDisabled)be good enough? Or would we need something likeif (_isClosed || _isDisabled)?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.
I think if we did:
would work.