From b3cc9b34c32269f39025b778e54ebbef663b8c21 Mon Sep 17 00:00:00 2001 From: fzaninotto Date: Fri, 27 Oct 2023 13:51:30 +0200 Subject: [PATCH] Fix `` keeps state between pages Closes #9394 --- packages/ra-ui-materialui/src/button/CreateButton.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/ra-ui-materialui/src/button/CreateButton.tsx b/packages/ra-ui-materialui/src/button/CreateButton.tsx index 66de564b4cf..5f6a85164d9 100644 --- a/packages/ra-ui-materialui/src/button/CreateButton.tsx +++ b/packages/ra-ui-materialui/src/button/CreateButton.tsx @@ -43,7 +43,11 @@ const CreateButton = (props: CreateButtonProps) => { const isSmall = useMediaQuery((theme: Theme) => theme.breakpoints.down('md') ); - const state = merge(scrollStates.get(String(scrollToTop)), initialState); + const state = merge( + {}, + scrollStates.get(String(scrollToTop)), + initialState + ); // Duplicated behaviour of Button component (legacy use) which will be removed in v5. const linkParams = getLinkParams(locationDescriptor); @@ -135,7 +139,8 @@ export default React.memo(CreateButton, (prevProps, nextProps) => { prevProps.label === nextProps.label && prevProps.translate === nextProps.translate && prevProps.disabled === nextProps.disabled && - isEqual(prevProps.to, nextProps.to) + isEqual(prevProps.to, nextProps.to) && + isEqual(prevProps.state, nextProps.state) ); });