Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.

Disabled Bellows should prevent close behaviour #56

Merged
marlowpayne merged 6 commits intomasterfrom
disable-close
Apr 21, 2015
Merged

Disabled Bellows should prevent close behaviour #56
marlowpayne merged 6 commits intomasterfrom
disable-close

Conversation

@marlowpayne
Copy link

Status: Ready for Review
Owner: @marlowpayne
Reviewers: @scalvert @kpeatt @tedtate @Helen-Mobify

Changes

  • To me, adding the bellows--is-disabled class to a bellows__item should mean that we can start with the Bellows item either open or closed. Currently this disabled class only affects the opening behaviour of a Bellows item, and thus if an item starts open the behaviour pattern is open -> permanently closed, where it should simply be permanently open.
  • I have simply added the same check for the disabled class from the open method to the close method, and wrote a new test for it

Todos:

  • Engineer +1

Feedback:

none so far

How to Test

  • Checkout the branch
  • Run grunt test and grunt test:browser

@kpeatt
Copy link
Contributor

kpeatt commented Apr 20, 2015

Logic makes sense to me.

Copy link
Contributor

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 _isOpen function to encapsulate this?

Copy link
Author

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.

Copy link
Contributor

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?

Copy link
Author

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 _isOpen won'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.

Copy link
Contributor

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.

Copy link
Author

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 like if (_isClosed || _isDisabled)?

Copy link
Contributor

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:

if (!this._isOpen() || this._isDisabled())

would work.

@marlowpayne
Copy link
Author

Pushed up those helper methods. @scalvert could you please have another look and let me know what you think. Thanks!

…never animating when this call fires. Also removed the redundant _item function calls in the _isOpen and _isDisabled functions
@scalvert
Copy link
Contributor

@marlowpayne OK I made a few small changes to clean things up a bit. Take a peek and if you're OK with the changes we can merge.

👍 from me at this point!

@marlowpayne
Copy link
Author

Looking nice and clean. Thanks @scalvert ! Are you handling version bumping and tagging?

@scalvert
Copy link
Contributor

Do you want to? How about I walk you through it?

marlowpayne pushed a commit that referenced this pull request Apr 21, 2015
Disabled Bellows should prevent close behaviour
@marlowpayne marlowpayne merged commit fdff1f6 into master Apr 21, 2015
@marlowpayne marlowpayne deleted the disable-close branch April 21, 2015 20:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants