Commit 915998b0 authored by Dave Schuyler's avatar Dave Schuyler Committed by Commit Bot

[MD settings] cookies, clear filter after removing items

This CL adds a listener to the settings subpage that will allow setting
the filter value. The filter may be cleared by setting the value to ''.

Bug: 770423
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: If4ac8e4bb1f1b38224b52e970f549293ff9b5e9d
Reviewed-on: https://chromium-review.googlesource.com/693390
Commit-Queue: Dave Schuyler <dschuyler@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506486}
parent 9d8ff7e9
......@@ -49,6 +49,31 @@ Polymer({
},
},
/** @override */
attached: function() {
if (!!this.searchLabel) {
// |searchLabel| should not change dynamically.
this.listen(this, 'clear-subpage-search', 'onClearSubpageSearch_');
}
},
/** @override */
detached: function() {
if (!!this.searchLabel) {
// |searchLabel| should not change dynamically.
this.unlisten(this, 'clear-subpage-search', 'onClearSubpageSearch_');
}
},
/**
* Clear the value of the search field.
* @param {!Event} e
*/
onClearSubpageSearch_: function(e) {
e.stopPropagation();
this.$$('settings-subpage-search').setValue('');
},
/** @private */
onTapBack_: function() {
settings.navigateToPreviousRoute();
......
......@@ -159,7 +159,7 @@ Polymer({
this.browserProxy_.removeCookie(items[i].id);
}
// We just deleted all items found by the filter, let's reset the filter.
/** @type {SettingsSubpageSearchElement} */ (this.$.filter).setValue('');
this.fire('clear-subpage-search');
}
},
......
......@@ -4,9 +4,25 @@
cr.define('settings_subpage', function() {
suite('SettingsSubpage', function() {
test('navigates to parent when there is no history', function() {
setup(function() {
PolymerTest.clearBody();
});
test('clear search', function() {
var subpage = document.createElement('settings-subpage');
// Having a searchLabel will create the settings-subpage-search.
subpage.searchLabel = 'test';
document.body.appendChild(subpage);
Polymer.dom.flush();
var search = subpage.$$('settings-subpage-search');
assertTrue(!!search);
search.setValue('Hello');
subpage.fire('clear-subpage-search');
Polymer.dom.flush();
assertEquals('', search.getValue());
});
test('navigates to parent when there is no history', function() {
// Pretend that we initially started on the CERTIFICATES route.
window.history.replaceState(
undefined, '', settings.routes.CERTIFICATES.path);
......@@ -21,8 +37,6 @@ cr.define('settings_subpage', function() {
});
test('navigates to any route via window.back()', function(done) {
PolymerTest.clearBody();
settings.navigateTo(settings.routes.BASIC);
settings.navigateTo(settings.routes.SYNC);
assertEquals(settings.routes.SYNC, settings.getCurrentRoute());
......
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