Skip to content

Commit

Permalink
Fix <CreateButton> keeps state between pages
Browse files Browse the repository at this point in the history
Closes #9394
  • Loading branch information
fzaninotto committed Oct 27, 2023
1 parent b93c6a2 commit b3cc9b3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/ra-ui-materialui/src/button/CreateButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
);
});

Expand Down

0 comments on commit b3cc9b3

Please sign in to comment.