Skip to content

Commit

Permalink
Added check to lead-art image
Browse files Browse the repository at this point in the history
  • Loading branch information
Malavika Koppula committed Mar 26, 2024
1 parent 8432f99 commit 9d23b31
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions blocks/lead-art-block/features/leadart/default.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,6 @@ export const LeadArtPresentation = (props) => {
viewportPercentage = 65
} = customFields;

useEffect(() => {
if (document.fullscreenEnabled) {
document.addEventListener("fullscreenchange", () => {
if (!document.fullscreenElement) {
setIsOpen(false);
}
});
} else if (document.webkitFullscreenEnabled) {
document.addEventListener("webkitfullscreenchange", () => {
if (!document.webkitFullscreenElement) {
setIsOpen(false);
}
})
}
}, []);

/* istanbul ignore next */
const toggleFullScreen = () => {
// the full screen element is the div wrapping a lead art of type image
Expand Down Expand Up @@ -277,6 +261,25 @@ export const LeadArtPresentation = (props) => {

const lead_art = content?.promo_items?.lead_art || content?.promo_items?.basic || {};
const leadArtContent = getLeadArtContent(lead_art);

useEffect(() => {
if(leadArtContent.type === "image"){
if (document.fullscreenEnabled) {
document.addEventListener("fullscreenchange", () => {
if (!document.fullscreenElement) {
setIsOpen(false);
}
});
} else if (document.webkitFullscreenEnabled) {
document.addEventListener("webkitfullscreenchange", () => {
if (!document.webkitFullscreenElement) {
setIsOpen(false);
}
})
}
}
}, [leadArtContent]);

if (leadArtContent) {
return <div className={BLOCK_CLASS_NAME}>{leadArtContent}</div>;
}
Expand Down

0 comments on commit 9d23b31

Please sign in to comment.