From c8965186008f4f4b95a2b3d276062823da847229 Mon Sep 17 00:00:00 2001 From: Mira Fedas <30750556+mirafedas@users.noreply.github.com> Date: Thu, 11 Jul 2024 14:17:08 +0200 Subject: [PATCH] MWPW-151513: Search results vanished when user clicks on Marquee CTA:Start free trail (#2406) * added restoring the search hash in modal * fixed unit test * updated merch-card-collection --- .../merch-card-collection/merch-card-collection.js | 2 +- libs/blocks/modal/modal.js | 8 ++++++++ libs/deps/merch-card-collection.js | 10 +++++----- .../mocks/merch-card-collection.html | 2 +- test/blocks/modals/modals.test.js | 14 ++++++++++++++ 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/libs/blocks/merch-card-collection/merch-card-collection.js b/libs/blocks/merch-card-collection/merch-card-collection.js index c124d7dd8a..b5716f6599 100644 --- a/libs/blocks/merch-card-collection/merch-card-collection.js +++ b/libs/blocks/merch-card-collection/merch-card-collection.js @@ -36,7 +36,7 @@ const fail = (el, err = '') => { return el; }; -/** Parse andd prepare cards */ +/** Parse and prepare cards */ async function getCardsRoot(config, html) { const cards = `
${html}
`; const fragment = document.createRange().createContextualFragment( diff --git a/libs/blocks/modal/modal.js b/libs/blocks/modal/modal.js index d8cef368fb..a6298b8c03 100644 --- a/libs/blocks/modal/modal.js +++ b/libs/blocks/modal/modal.js @@ -12,6 +12,7 @@ const CLOSE_ICON = `{l?e.set(i,l):e.delete(i)}),e.sort();let t=e.toString(),o=window.scrollY||document.documentElement.scrollTop;window.location.hash=t,window.scrollTo(0,o)}function x(r){let e=()=>{let t=S(window.location.hash);r(t)};return e(),window.addEventListener(E,e),()=>{window.removeEventListener(E,e)}}var g=(r,e={})=>{r.querySelectorAll("span[data-placeholder]").forEach(t=>{let{placeholder:o}=t.dataset;t.innerText=e[o]??""})};var T="(max-width: 1199px)",y="(min-width: 768px)",C="(min-width: 1200px)";import{css as _,unsafeCSS as b}from"/libs/deps/lit-all.min.js";var w=_` +// branch: main commit: dd5f72e1449ed667f48ef5be086043ddf9cc113d Mon, 24 Jun 2024 12:52:40 GMT +import{html as a,LitElement as N}from"/libs/deps/lit-all.min.js";var m=class{constructor(e,t){this.key=Symbol("match-media-key"),this.matches=!1,this.host=e,this.host.addController(this),this.media=window.matchMedia(t),this.matches=this.media.matches,this.onChange=this.onChange.bind(this),e.addController(this)}hostConnected(){var e;(e=this.media)==null||e.addEventListener("change",this.onChange)}hostDisconnected(){var e;(e=this.media)==null||e.removeEventListener("change",this.onChange)}onChange(e){this.matches!==e.matches&&(this.matches=e.matches,this.host.requestUpdate(this.key,!this.matches))}};var E="hashchange";function S(r=window.location.hash){let e=[],t=r.replace(/^#/,"").split("&");for(let o of t){let[i,l=""]=o.split("=");i&&e.push([i,decodeURIComponent(l.replace(/\+/g," "))])}return Object.fromEntries(e)}function p(r){let e=new URLSearchParams(window.location.hash.slice(1));Object.entries(r).forEach(([i,l])=>{l?e.set(i,l):e.delete(i)}),e.sort();let t=e.toString(),o=window.scrollY||document.documentElement.scrollTop;window.location.hash=t,window.scrollTo(0,o)}function x(r){let e=()=>{if(!window.location.hash.includes("="))return;let t=S(window.location.hash);r(t)};return e(),window.addEventListener(E,e),()=>{window.removeEventListener(E,e)}}var g=(r,e={})=>{r.querySelectorAll("span[data-placeholder]").forEach(t=>{let{placeholder:o}=t.dataset;t.innerText=e[o]??""})};var T="(max-width: 1199px)",y="(min-width: 768px)",C="(min-width: 1200px)";import{css as _,unsafeCSS as w}from"/libs/deps/lit-all.min.js";var b=_` #header, #resultText, #footer { @@ -62,7 +62,7 @@ import{html as a,LitElement as N}from"/libs/deps/lit-all.min.js";var m=class{con } /* tablets */ - @media screen and ${b(y)} { + @media screen and ${w(y)} { #header { grid-template-columns: 1fr fit-content(100%) fit-content(100%); } @@ -81,7 +81,7 @@ import{html as a,LitElement as N}from"/libs/deps/lit-all.min.js";var m=class{con } /* Laptop */ - @media screen and ${b(C)} { + @media screen and ${w(C)} { #resultText { grid-column: span 2; order: -3; @@ -144,4 +144,4 @@ import{html as a,LitElement as N}from"/libs/deps/lit-all.min.js";var m=class{con >${o} - `}sortChanged(e){e.target.value===n.authored?p({sort:void 0}):p({sort:e.target.value})}async showMore(){let e=this.page+1;p({page:e}),this.page=e,await this.updateComplete}startDeeplink(){this.stopDeeplink=x(({category:e,filter:t,types:o,sort:i,search:l,single_app:c,page:d})=>{t=t||e,!this.filtered&&t&&t!==this.filter&&setTimeout(()=>{p({page:void 0}),this.page=1},1),this.filtered||(this.filter=t??this.filter),this.types=o??"",this.search=l??"",this.singleApp=c,this.sort=i,this.page=Number(d)||1})}openFilters(e){this.sidenav?.showModal(e)}static styles=[w]};f.SortOrder=n;customElements.define(A,f);export{f as MerchCardCollection}; + `}sortChanged(e){e.target.value===n.authored?p({sort:void 0}):p({sort:e.target.value})}async showMore(){let e=this.page+1;p({page:e}),this.page=e,await this.updateComplete}startDeeplink(){this.stopDeeplink=x(({category:e,filter:t,types:o,sort:i,search:l,single_app:c,page:d})=>{t=t||e,!this.filtered&&t&&t!==this.filter&&setTimeout(()=>{p({page:void 0}),this.page=1},1),this.filtered||(this.filter=t??this.filter),this.types=o??"",this.search=l??"",this.singleApp=c,this.sort=i,this.page=Number(d)||1})}openFilters(e){this.sidenav?.showModal(e)}static styles=[b]};f.SortOrder=n;customElements.define(A,f);export{f as MerchCardCollection}; diff --git a/test/blocks/merch-card-collection/mocks/merch-card-collection.html b/test/blocks/merch-card-collection/mocks/merch-card-collection.html index 09111593b1..7fc9632d2f 100644 --- a/test/blocks/merch-card-collection/mocks/merch-card-collection.html +++ b/test/blocks/merch-card-collection/mocks/merch-card-collection.html @@ -173,7 +173,7 @@ -

Search all products

Filters

Sort

Popularity

Alphabetical

0 results

1 result in

results in

1 result for

results for

1 result for:

results for:

Your search for did not yield any results

Your search for did not yield any results. Try a different search term.

Suggestions: