Commit cd01dc89 by muhammad-ammar Committed by muzaffaryousaf

clear search input when search results tab is closed

TNL-4055
parent ce57700d
......@@ -29,9 +29,15 @@ define([
this.logger = NotesLogger.getLogger('search_box', this.options.debug);
this.$el.removeClass('is-hidden');
this.isDisabled = false;
this.searchInput = this.$el.find('#search-notes-input');
this.logger.log('initialized');
},
clearInput: function() {
// clear the search input box
this.searchInput.val('');
},
submitHandler: function (event) {
event.preventDefault();
this.search();
......
......@@ -105,6 +105,7 @@ define([
onClose: function () {
this.searchResults = null;
this.searchBox.clearInput();
},
onBeforeSearchStart: function () {
......
......@@ -164,5 +164,11 @@ define([
' '
);
});
it('can clear its input box', function () {
this.searchBox.$('.search-notes-input').val('search me');
this.searchBox.clearInput();
expect(this.searchBox.$('#search-notes-input').val()).toEqual('');
});
});
});
......@@ -146,12 +146,14 @@ define([
it('can clear search results if tab is closed', function () {
var view = getView(this.tabsCollection),
requests = AjaxHelpers.requests(this);
spyOn(view.searchBox, 'clearInput').andCallThrough();
submitForm(view.searchBox, 'test_query');
Helpers.respondToRequest(requests, responseJson, true);
expect(view.searchResults).toBeDefined();
this.tabsCollection.at(0).destroy();
expect(view.searchResults).toBeNull();
expect(view.searchBox.clearInput).toHaveBeenCalled();
});
it('can correctly show/hide error messages', function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment