Skip to content
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

Contrast and small UX fix for the search button #2708

Merged
merged 7 commits into from
Mar 11, 2015
Merged

Contrast and small UX fix for the search button #2708

merged 7 commits into from
Mar 11, 2015

Conversation

saleiva
Copy link
Contributor

@saleiva saleiva commented Mar 11, 2015

Search button should close the search state if clicked again

@saleiva
Copy link
Contributor Author

saleiva commented Mar 11, 2015

screen shot 2015-03-11 at 09 12 34

Hey @xavijam @viddo @carlostallon CR this, please.
DISCLAIMER: I didn't manage to run the test suite, but having a test for this would be great.

@saleiva
Copy link
Contributor Author

saleiva commented Mar 11, 2015

Ok I've just detected a bug here. I need to clean the search also when clicking (if search applied)

this.$('.js-search-input').focus();

active = this.$('.Filters-inner').hasClass('search--enabled')
this.$('.Filters-inner')[ active ? 'removeClass' : 'addClass' ]('search--enabled');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this.$('.Filters-inner').toggleClass('search--enabled')work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed on the last commit as I found another thing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Checking current state is better done through models than the DOM, since the models act as "source of truth" and makes it easier to reason about the code.
  2. There is already exist a method that updates the state properly (and the view re-renders accordingly), so I would use that instead than fiddling with the visual state manually.

Thus, I would the replace the changes here with something like:

// TODO: taken from line 119, I would wrap this check in a semantic method like router.model.isSearch()
//   if (this.router.model.isSearch()) {
if (this.router.model.get('q') || this.router.model.get('tag')) { 
  this._onCleanSearchClick()
} else {
  this.$('.Filters-inner').addClass('search--enabled');
  this.$('.js-search-input').focus();
}

@@ -233,8 +233,14 @@ module.exports = cdb.core.View.extend({

_onSearchClick: function(e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the readability / style on this method.

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 it's fine

@xavijam
Copy link
Contributor

xavijam commented Mar 11, 2015

@viddo will review this one and I'll review #2655

Nicklas Gummesson added 2 commits March 11, 2015 12:38
- Make variables private to function scope
- Extract isSearching check to router model
@viddo
Copy link
Contributor

viddo commented Mar 11, 2015

@saleiva Found some (code) issues while reviewing it locally, so refactored it a little, and added test cases while at it (see last two commits).

I'll take care of merging & releasing it with my other pending PRs.

Thanks for the contributions. :)

@Cartofante
Copy link
Collaborator

Frontend tests were OK 👍 (details)

@saleiva
Copy link
Contributor Author

saleiva commented Mar 11, 2015

cool!

viddo added a commit that referenced this pull request Mar 11, 2015
Contrast and small UX fix for the search button
@viddo viddo merged commit 86a7ef7 into master Mar 11, 2015
@viddo viddo deleted the searchbutton branch March 11, 2015 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants