Skip to content

Commit

Permalink
Fixed getCurrentLayout SSR issue
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Mar 15, 2022
1 parent 73338c0 commit 32fdd3a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,7 +2,9 @@

## 0.14.19 (tbd)

- Improved pilet injector to always return an array as metadata response
- Removed dependency to `webpack-inject-plugin` in `piral-cli-webpack5`
- Fixed issue with `getCurrentLayout` not returning default layout in SSR

## 0.14.18 (March 15, 2022)

Expand Down
5 changes: 2 additions & 3 deletions jest.config.js
@@ -1,4 +1,3 @@
module.exports = {
testEnvironment: 'jsdom',
...require('piral-jest-utils').default
}
...require('piral-jest-utils').default,
};
3 changes: 1 addition & 2 deletions src/framework/piral-core/src/utils/media.ts
@@ -1,5 +1,4 @@
import { isfunc } from 'piral-base';
import { none } from './helpers';
import { LayoutTypes, LayoutBreakpoints } from '../types';

export const defaultLayouts: LayoutTypes = ['desktop', 'tablet', 'mobile'];
Expand All @@ -8,7 +7,7 @@ export const defaultBreakpoints: LayoutBreakpoints = ['(min-width: 991px)', '(mi

const mm =
typeof window === 'undefined' || !isfunc(window.matchMedia)
? () => ({ matches: none })
? () => ({ matches: undefined })
: (q: string) => window.matchMedia(q);

export function getCurrentLayout<T>(breakpoints: Array<string>, layouts: Array<T>, defaultLayout: T) {
Expand Down
5 changes: 0 additions & 5 deletions src/tooling/piral-cli/src/injectors/pilet.ts
Expand Up @@ -128,11 +128,6 @@ export default class PiletInjector implements KrasInjector {
const { pilets, feed } = this.config;
const localPilets = pilets.map((pilet) => pilet.meta).filter(Boolean);
const mergedPilets = this.mergePilets(localPilets, await this.loadRemoteFeed(feed));

if (mergedPilets.length === 1) {
return JSON.stringify(mergedPilets[0]);
}

return JSON.stringify(mergedPilets);
}

Expand Down
1 change: 1 addition & 0 deletions src/utilities/piral-jest-utils/src/config.ts
Expand Up @@ -5,6 +5,7 @@ const config: Config.InitialOptions = {
collectCoverage: true,
setupFiles: [resolve(__dirname, 'setup.js')],
roots: ['src/'],
testEnvironment: 'jsdom',
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.jsx?$': 'babel-jest',
Expand Down

0 comments on commit 32fdd3a

Please sign in to comment.