Skip to content

Commit 5a4a704

Browse files
Merge pull request #5185 from topcoder-platform/media-queries-fix
Media queries fix
2 parents b6fe5e6 + d7b3ce0 commit 5a4a704

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ workflows:
259259
filters:
260260
branches:
261261
only:
262-
- pass-screen-updates
262+
- develop
263263
# Production builds are exectuted
264264
# when PR is merged to the master
265265
# Don't change anything in this configuration

src/shared/containers/ContentfulLoader.jsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import React from 'react';
1111
import shortId from 'shortid';
1212
import qs from 'qs';
1313
import SSR from 'utils/SSR';
14-
import { config } from 'topcoder-react-utils';
14+
import { config, isomorphy } from 'topcoder-react-utils';
1515
import { connect } from 'react-redux';
1616

1717
// Setting those to infinity to disable maxage and auto refresh
@@ -156,6 +156,10 @@ class ContentfulLoader extends React.Component {
156156
const b = this.loadContentOnMount(entryIds, 'entries', timeLimit);
157157
const c = this.loadQueriesOnMount(assetQueries, 'assets', timeLimit);
158158
const d = this.loadQueriesOnMount(entryQueries, 'entries', timeLimit);
159+
if (isomorphy.isClientSide()) {
160+
this.handleResize = _.throttle(this.handleResize.bind(this), 250);
161+
window.addEventListener('resize', this.handleResize);
162+
}
159163
return Promise.all([...a, ...b, ...c, ...d])
160164
.then(() => new Promise(resolve => setTimeout(() => resolve(), 100)));
161165
}
@@ -208,6 +212,18 @@ class ContentfulLoader extends React.Component {
208212
const ids = toArray(entryQueries).map(query => queryToMd5(query));
209213
ids.forEach(id => freeQuery(id, 'entries', preview, spaceName, environment));
210214
}
215+
216+
if (isomorphy.isClientSide()) {
217+
window.removeEventListener('resize', this.handleResize);
218+
}
219+
}
220+
221+
/**
222+
* On window resize trigger render
223+
* for this and all child componets
224+
*/
225+
handleResize() {
226+
this.forceUpdate();
211227
}
212228

213229
/**

0 commit comments

Comments
 (0)