Skip to content

Commit

Permalink
Merge pull request #9407 from marmelab/fix-createbutton-state
Browse files Browse the repository at this point in the history
Fix `<CreateButton>` keeps state between pages
  • Loading branch information
fzaninotto authored Oct 27, 2023
2 parents b93c6a2 + b3cc9b3 commit 3a5e84e
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 3a5e84e

Please sign in to comment.