Commit 33ebdcf6 authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Revert "WebUI Modules: shopping tasks, hide elements that do not fit"

This reverts commit d30e1594.

Reason for revert: NewTabPageModulesShoppingTasksModuleTest.All fails consistently on linux-chromeos-chrome

BUG=1134274

Original change's description:
> WebUI Modules: shopping tasks, hide elements that do not fit
>
> Bug: 1132424
> Change-Id: I1b56fdec5c37d81a4939e986b3282af4585772ee
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2440970
> Commit-Queue: Esmael Elmoslimany <aee@chromium.org>
> Reviewed-by: Tibor Goldschwendt <tiborg@chromium.org>
> Auto-Submit: Esmael Elmoslimany <aee@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#812569}

TBR=tiborg@chromium.org,aee@chromium.org

Change-Id: Ia0be2a22e0ffa23c22a18adc78f26de5eb729e48
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1132424
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2443277Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812844}
parent 5be43b2f
......@@ -133,7 +133,7 @@
</style>
<div id="products">
<template is="dom-repeat" id="productsRepeat"
items="[[shoppingTask.products]]" on-dom-change="onDomChange_">
items="[[shoppingTask.products]]">
<a class="product" href="[[item.targetUrl.url]]" on-click="onClick_"
on-auxclick="onClick_">
<div class="image">
......@@ -146,8 +146,8 @@
</template>
</div>
<div id="relatedSearches">
<template is="dom-repeat" id="relatedSearchesRepeat"
items="[[shoppingTask.relatedSearches]]" on-dom-change="onDomChange_">
<template is="dom-repeat" id="relatedSearchesRepeat"
items="[[shoppingTask.relatedSearches]]">
<a class="pill" href="[[item.targetUrl.url]]" on-click="onClick_"
on-auxclick="onClick_">
<div class="loupe"></div>
......
......@@ -34,13 +34,6 @@ class ShoppingTasksModuleElement extends PolymerElement {
};
}
/** @override */
ready() {
super.ready();
/** @type {IntersectionObserver} */
this.intersectionObserver_ = null;
}
/** @private */
onClick_() {
this.dispatchEvent(new Event('usage', {bubbles: true, composed: true}));
......@@ -50,22 +43,6 @@ class ShoppingTasksModuleElement extends PolymerElement {
onCloseClick_() {
this.showInfoDialog = false;
}
/** @private */
onDomChange_() {
if (!this.intersectionObserver_) {
this.intersectionObserver_ = new IntersectionObserver(entries => {
entries.forEach(({intersectionRatio, target}) => {
target.style.visibility =
intersectionRatio < 1 ? 'hidden' : 'visible';
});
}, {root: this, threshold: 1});
} else {
this.intersectionObserver_.disconnect();
}
this.shadowRoot.querySelectorAll('.product, .pill')
.forEach(el => this.intersectionObserver_.observe(el));
}
}
customElements.define(
......
......@@ -4,7 +4,6 @@
import {shoppingTasksDescriptor, ShoppingTasksHandlerProxy} from 'chrome://new-tab-page/new_tab_page.js';
import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js';
import {flushTasks} from 'chrome://test/test_util.m.js';
suite('NewTabPageModulesShoppingTasksModuleTest', () => {
/**
......@@ -103,45 +102,4 @@ suite('NewTabPageModulesShoppingTasksModuleTest', () => {
assertEquals('https://blub.com/', pills[1].href);
assertEquals('blub', pills[1].querySelector('.search-text').innerText);
});
test('products and pills are hidden when cutoff', async () => {
const repeat = (n, fn) => Array(n).fill(0).map(fn);
testProxy.handler.setResultFor('getPrimaryShoppingTask', Promise.resolve({
shoppingTask: {
title: 'Hello world',
products: repeat(20, () => ({
name: 'foo',
imageUrl: {url: 'https://foo.com/img.png'},
price: '1 gazillion dollars',
info: 'foo info',
targetUrl: {url: 'https://foo.com'},
})),
relatedSearches: repeat(20, () => ({
text: 'baz',
targetUrl: {url: 'https://baz.com'},
})),
}
}));
await shoppingTasksDescriptor.initialize();
const moduleElement = shoppingTasksDescriptor.element;
document.body.append(moduleElement);
moduleElement.$.productsRepeat.render();
moduleElement.$.relatedSearchesRepeat.render();
const getElements = () => Array.from(
moduleElement.shadowRoot.querySelectorAll('.product, .pill'));
assertEquals(40, getElements().length);
const hiddenCount = () =>
getElements().filter(el => el.style.visibility === 'hidden').length;
const checkHidden = async (width, count) => {
moduleElement.style.width = width;
await flushTasks();
await flushTasks();
await flushTasks();
assertEquals(count, hiddenCount());
};
await checkHidden('500px', 31);
await checkHidden('300px', 35);
await checkHidden('700px', 26);
await checkHidden('500px', 31);
});
});
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