Skip to content
Snippets Groups Projects
Commit b987c31e authored by Ben Mullins's avatar Ben Mullins Committed by Jesse Baker
Browse files

Issue #3461584 by bnjmnm: <Viewport> hard codes ids, leading to multiple

parent 585a80db
No related branches found
No related tags found
1 merge request!98Address duplicate <Viewport> ids
Pipeline #226469 passed
......@@ -260,14 +260,14 @@ Cypress.Commands.add('drupalSession', () => {
})
})
Cypress.Commands.add('getPreviewIframe', () => {
Cypress.Commands.add('getPreviewIframe', (selector = '[data-xb-preview]') => {
return cy
.get('iframe#preview')
.get(selector)
.its('0.contentDocument').should('exist')
})
Cypress.Commands.add('getPreviewBody', () => {
return cy.getPreviewIframe()
Cypress.Commands.add('getPreviewBody', (selector = '[data-xb-preview]') => {
return cy.getPreviewIframe(selector)
.its('body').should('not.be.undefined')
.then(cy.wrap)
})
......@@ -36,12 +36,14 @@ const Preview: React.FC<PreviewProps> = () => {
return (
<>
<Viewport
previewId='lg'
height={768}
width={1024}
frameSrcDoc={frameSrcDoc}
isLoading={isLoading}
/>
<Viewport
previewId='sm'
height={768}
width={400}
frameSrcDoc={frameSrcDoc}
......
......@@ -29,6 +29,7 @@ import useIframeKeyHandlers from '@/hooks/useIframeKeyHandlers';
import useSyncIframeHeightToContent from '@/hooks/useSyncIframeHeightToContent';
interface ViewportProps {
previewId: string;
height: number;
width: number;
isLoading: boolean;
......@@ -36,7 +37,7 @@ interface ViewportProps {
}
const Viewport: React.FC<ViewportProps> = (props) => {
const { height, width, frameSrcDoc, isLoading } = props;
const { height, width, frameSrcDoc, isLoading, previewId } = props;
const iframeRef = useRef<HTMLIFrameElement>(null);
const layout = useAppSelector(selectLayout);
const model = useAppSelector(selectModel);
......@@ -232,7 +233,7 @@ const Viewport: React.FC<ViewportProps> = (props) => {
<iframe
ref={iframeRef}
className={styles.preview}
id="preview"
data-xb-preview={previewId}
title="Preview"
srcDoc={frameSrcDoc}
></iframe>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment