Skip to content

Commit

Permalink
Show error on Save&Close buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Jan 6, 2025
1 parent 41f2015 commit 29a3f96
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/adapter-react-v5/src/GenericApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -929,14 +929,15 @@ export class GenericApp<
this.state.width === 'xs' || this.state.width === 'sm' || this.state.width === 'md'
}
changed={this.state.changed}
onSave={isClose => this.onSave(isClose)}
onClose={() => {
onSave={(isClose: boolean): void => this.onSave(isClose)}
onClose={(): void => {
if (this.state.changed) {
this.setState({ confirmClose: true });
} else {
GenericApp.onClose();
}
}}
error={!!this.state.isConfigurationError}
/>
) : null}
{this.state.confirmClose ? (
Expand All @@ -945,7 +946,9 @@ export class GenericApp<
text={I18n.t('ra_Some data are not stored. Discard?')}
ok={I18n.t('ra_Discard')}
cancel={I18n.t('ra_Cancel')}
onClose={isYes => this.setState({ confirmClose: false }, () => isYes && GenericApp.onClose())}
onClose={(isYes: boolean): void =>
this.setState({ confirmClose: false }, () => isYes && GenericApp.onClose())
}
/>
) : null}
</>
Expand Down

0 comments on commit 29a3f96

Please sign in to comment.