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): force re-render for stale RuleForm #82842

Merged
merged 2 commits into from
Jan 3, 2025

Conversation

natemoo-re
Copy link
Member

Closes #82335.

This PR "fixes" a state bug that occurs when an Alert is edited, saved, and then edited again. It's an admittedly gross hack, but we're about to completely refactor the RuleForm component as part of the Alerts Create Issues (ACI) project, so fixing this properly would be wasted effort.

Explanation

The bug occurs because the RuleForm component derives many pieces of internal state from the rule prop. However, because the internal state is only derived when the component mounts, subsequent updates to the rule prop are never propagated to the derived state values, causing the state to get out-of-sync with the fresh rule data.

Bugs of this nature are common with class-based components, which is why the codebase now uses functional components with react-query. We'll be migrating this area of the codebase to these new patterns in ACI.

@natemoo-re natemoo-re requested a review from a team as a code owner January 2, 2025 23:04
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 2, 2025
Copy link
Contributor

@saponifi3d saponifi3d left a comment

Choose a reason for hiding this comment

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

excited for the refactor to react-query 🎉

@natemoo-re natemoo-re enabled auto-merge (squash) January 3, 2025 15:34
@natemoo-re natemoo-re merged commit ec0f3f1 into master Jan 3, 2025
42 checks passed
@natemoo-re natemoo-re deleted the fix/alert-edit-state branch January 3, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alert rule edit page uses previous alert rule data
2 participants