diff --git a/CHANGELOG.md b/CHANGELOG.md index a0c2e1ba..89092d92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Fixed a bug where removing all items from review block would send the user to a "Nothing to Show" page. + ## [3.15.4] - 2024-06-13 ## [3.15.3] - 2024-06-10 diff --git a/react/TextAreaBlock.tsx b/react/TextAreaBlock.tsx index 613ecbb8..17304f04 100644 --- a/react/TextAreaBlock.tsx +++ b/react/TextAreaBlock.tsx @@ -15,7 +15,7 @@ import { usePixel } from 'vtex.pixel-manager/PixelContext' import { categoryMessages as messages } from './utils/messages' import ReviewBlock from './components/ReviewBlock' -import { ParseText, GetText } from './utils' +import { ParseText } from './utils' interface ItemType { id: string @@ -156,7 +156,7 @@ const TextAreaBlock: FunctionComponent< } const onReviewItems = (items: any) => { - if (items) { + if (items?.length) { const show = items.filter((item: any) => { return item.error @@ -167,9 +167,8 @@ const TextAreaBlock: FunctionComponent< reviewItems: items, reviewState: true, showAddToCart: show, - textAreaValue: GetText(items), }) - } + } else backList() return true } diff --git a/react/UploadBlock.tsx b/react/UploadBlock.tsx index 9bec6ef0..9bec7718 100644 --- a/react/UploadBlock.tsx +++ b/react/UploadBlock.tsx @@ -116,8 +116,11 @@ const UploadBlock: FunctionComponent< } const onReviewItems = (items: any) => { - if (items) { - const show = !items.some((item: any) => item.error) + if (items?.length) { + const show = + items.filter((item: any) => { + return !item.vtexSku + }).length === 0 setState({ ...state, @@ -126,7 +129,7 @@ const UploadBlock: FunctionComponent< showAddToCart: alwaysShowAddToCart || show, textAreaValue: GetText(items), }) - } + } else backList() return true }