Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Alerts & Reports): Fixing bug that resets cron value to default when empty #27262

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion superset-frontend/src/features/alerts/AlertReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
key="schedule"
>
<AlertReportCronScheduler
value={currentAlert?.crontab || ALERT_REPORTS_DEFAULT_CRON_VALUE}
value={currentAlert?.crontab || ''}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have much context here but this does look problematic. Is the default being completely ignored? I don't see other uses of the variable. Maybe @eschutho can help here.

Copy link
Contributor Author

@fisjac fisjac Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is being set when a new alert/report is generated, so the user should always open the modal to a valid schedule input to start. The problem with the previous implementation is that when the user deletes the input and currentAlert?.crontab === '', it become falsey and resets to the default.

Perhaps we should consider an onBlur property to this field, where bluring an empty value resets to the default?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fisjac I think your idea about the onBlur event might work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we are validating empty CRON values, this change is fine.

onChange={newVal => updateAlertState('crontab', newVal)}
/>
<StyledInputContainer>
Expand Down
Loading