Skip to content

Commit

Permalink
Merge pull request #4339 from marmelab/useeditcontroller-inconsistency
Browse files Browse the repository at this point in the history
Ensure useEditController specifies a default redirect to its caller
  • Loading branch information
fzaninotto authored Jan 23, 2020
2 parents 4de9af2 + 15ff009 commit 53ce05c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/ra-core/src/controller/useEditController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface EditControllerProps {
resource: string;
basePath: string;
record?: Record;
redirect: RedirectionSideEffect;
version: number;
successMessage?: string;
}
Expand Down Expand Up @@ -101,7 +102,7 @@ const useEditController = (props: EditProps): EditControllerProps => {
const save = useCallback(
(
data: Partial<Record>,
redirectTo = 'list',
redirectTo = DefaultRedirect,
{ onSuccess, onFailure } = {}
) =>
update(
Expand Down Expand Up @@ -146,8 +147,11 @@ const useEditController = (props: EditProps): EditControllerProps => {
resource,
basePath,
record,
redirect: DefaultRedirect,
version,
};
};

export default useEditController;

const DefaultRedirect = 'list';

0 comments on commit 53ce05c

Please sign in to comment.