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 crash when canceling alert association #547

Merged
merged 1 commit into from
Oct 31, 2024
Merged

Conversation

panentheos
Copy link
Collaborator

Asana task: bug: UI crash when canceling out of alert linking on PA message form

This fixes an issue where starting an alert linkage and then canceling would crash the UI. The underlying issue was that the sub-form was directly updating some state on the main form, and so canceling would leave things in an inconsistent state. The fix isolates the sub-form with its own state, which is only applied to the main form when the "Apply" button is pressed.

This also demonstrates an approach to prop handling that I think is generally useful: Rather than passing setters down to sub-components and requiring them to update things directly, it's sometimes nicer to think about passing contextual callbacks (e.g. onApply, onSelectAlert) and performing the actual state changes higher up in the tree. This naturally centralizes state management (which is a good thing), and also tends to reduce the amount of "wiring" required between components.

@panentheos panentheos requested a review from a team as a code owner October 31, 2024 16:10
Copy link
Contributor

@digitalcora digitalcora left a comment

Choose a reason for hiding this comment

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

I'd agree this form of control flow makes the logic easier to follow and harder to make mistakes with. Approving so we can get the fix out, but @cmaddox5 and @PaulJKim have had much more involvement with this code, so everyone should take a look!

@panentheos panentheos merged commit 469c426 into main Oct 31, 2024
3 checks passed
@panentheos panentheos deleted the bhw/associate-alert branch October 31, 2024 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants