From 5c27ec7212c4520c2b5fcf29bf4d352cf920a86e Mon Sep 17 00:00:00 2001 From: ariel_rodriguez Date: Wed, 6 Dec 2023 14:41:32 -0300 Subject: [PATCH] fix: Validation was modified in the FileContent Validation was modified in the FileContent --- src/components/FileViewer/FileViewer.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/FileViewer/FileViewer.tsx b/src/components/FileViewer/FileViewer.tsx index 76480a60d..254b6be5b 100644 --- a/src/components/FileViewer/FileViewer.tsx +++ b/src/components/FileViewer/FileViewer.tsx @@ -2,7 +2,7 @@ * Copyright (c) DD360 and its affiliates. */ -import { HTMLProps, ReactNode, useMemo } from 'react' +import { HTMLProps, ReactNode, useEffect, useMemo, useState } from 'react' import { composeClasses } from 'lib/classes' import { composeStyles } from 'lib/styles' import { Portal } from 'common/Portal' @@ -147,11 +147,16 @@ const FileContent = ({ className, role = 'viewer-file-container' }: FileContentProps) => { - const encodedUrl = encodeURIComponent(url || '') + const [encodedUrl, setEncodedUrl] = useState(null) + + useEffect(() => { + if (!url) return + setEncodedUrl(encodeURIComponent(url)) + }, [fileType, url]) return ( <> - {url && url !== '' ? ( + {url ? (