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

Feature: add an "x"-button to clear the search box #749

Open
ronkorving opened this issue Apr 12, 2017 · 3 comments
Open

Feature: add an "x"-button to clear the search box #749

ronkorving opened this issue Apr 12, 2017 · 3 comments

Comments

@ronkorving
Copy link

ronkorving commented Apr 12, 2017

So many search fields these days come with a little "x" button in or around them (so you don't have to refocus the search field, then backspace the search string) that I naturally expected it in the search field on Slate as well. I think it would a nice and intuitive addition if that were to actually exist.

@PreciselyAlyss
Copy link

You can see part of my attempt to do this here. The functional parts are there, it just needs some cleanup.

@regevbr
Copy link

regevbr commented Jun 6, 2019

Hi any news on that?

@regevbr
Copy link

regevbr commented Jun 6, 2019

A quick feaute impel I used here - https://squiss-ts.pruvo.com is as follow:

searchClear

search.js - change the bind method as follows:

  function bind() {
    content = $('.content');
    searchResults = $('.search-results');

    function inputCallback(e) {
      var wait = function() {
        return function(executingFunction, waitTime){
          clearTimeout(timeoutHandle);
          timeoutHandle = setTimeout(executingFunction, waitTime);
        };
      }();
      wait(function(){
        search(e);
      }, searchDelay );
    }
    $('#input-search').on('search',inputCallback);
    $('#input-search').on('keyup',inputCallback);
  }

layout.erb - change the search div as follows:

        <div class="search">
          <input type="search" class="search" id="input-search" placeholder="Search">
        </div>

_normalize.css - remove the following:

input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants