From 3755384b663a0139118e8478f5c5d8d16df7f86b Mon Sep 17 00:00:00 2001 From: Ronald Langeveld Date: Mon, 11 Sep 2023 16:14:09 +0700 Subject: [PATCH] Fixed visibility updating announcement bar in AdminX (#18058) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - fixed an issue where toggling the visibility of the announcement bar doesn't update the preview. --- ### 🤖 Generated by Copilot at bad7a08 Simplified the `AnnouncementBarPreview` component by using a shallow equality check for the `visibility` prop. This is part of a refactor to use React hooks and functional components. --- .../site/announcementBar/AnnouncementBarPreview.tsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/apps/admin-x-settings/src/components/settings/site/announcementBar/AnnouncementBarPreview.tsx b/apps/admin-x-settings/src/components/settings/site/announcementBar/AnnouncementBarPreview.tsx index b0dfc44764..34a832a291 100644 --- a/apps/admin-x-settings/src/components/settings/site/announcementBar/AnnouncementBarPreview.tsx +++ b/apps/admin-x-settings/src/components/settings/site/announcementBar/AnnouncementBarPreview.tsx @@ -96,18 +96,10 @@ export default memo(AnnouncementBarPreview, (prevProps, nextProps) => { } // Check if visibility array changed in size or content - if (prevProps.visibility?.length !== nextProps.visibility?.length) { + if (prevProps.visibility !== nextProps.visibility) { return false; } - if (prevProps.visibility && nextProps.visibility) { - for (let i = 0; i < prevProps.visibility.length; i++) { - if (prevProps.visibility[i] !== nextProps.visibility[i]) { - return false; - } - } - } - // If we've reached this point, all props are the same return true; });