Skip to content

Commit

Permalink
Merge pull request #214 from futurice/fix-framing-behaviour
Browse files Browse the repository at this point in the history
Fix framing behaviour
  • Loading branch information
jareware authored Apr 8, 2020
2 parents ea2610e + 19be714 commit e8fe308
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/frontend/main/Survey.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React, { useEffect } from 'react';
import styled from 'styled-components';
import { RouteComponentProps } from '@reach/router';
import * as resizer from 'iframe-resizer';

// IMPORANT: We can't import the WHOLE library, just the "parent page" part!
// Including the "child page" part in our bundle is enough to activate it when the standalone site is framed,
// potentially causing an infinite resizing loop within the library. That is, before changing this import,
// BE VERY SURE you have tested both framing the standalone site, and the standalone site's capability to frame the embed site.
import * as iframeResizer from 'iframe-resizer/js/iframeResizer';

const Container = styled.div`
max-width: 632px;
Expand All @@ -16,7 +21,7 @@ const Iframe = styled.iframe`

const Survey = (props: RouteComponentProps) => {
useEffect(() => {
resizer.iframeResizer({ log: false }, '#formIframe');
iframeResizer({ log: false }, '#formIframe');
});

return (
Expand Down
4 changes: 4 additions & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
// Allow tsc to build our codebase even without webpack-specific tweaks
// See https://github.com/microsoft/TypeScript-React-Starter/issues/12
declare module '*.svg';

// We can't import the whole "iframe-resizer" library, so its typings aren't useful to us, either.
// See the import "iframe-resizer/js/iframeResizer" for details.
declare module 'iframe-resizer/js/iframeResizer';

0 comments on commit e8fe308

Please sign in to comment.