[FLAG-343] fire alert widget crashes page when clicking settings button #4703
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Unlike most other widgets where the widget settings are predefined, in this widget (
firesAlertsSimple
) the min/max/start dates for the datepickers in the settings are determined based on the dates fetched from an endpoint.The
integratedDeforestationAlerts
widget also works in a similar fashion and suffers from the same bug; although it fetches data from a glad endpoint instead.From what I learned during the debugging session, when the user opens the settings dropdown before the dates are available to populate the datepickers, the datepickers crash (
undefined
dates).I've considered a few options:
though this would mean re-engineering part of the core of the components that render the widgets in order to allow settings to be set asynchronously, which seems a bit overkill for just a couple outlier widgets
however, this would cause the button to flicker when the widget is loading data to display in its body, such as when the user changes its settings
This seemed like a flakey solution and more of a patch; which I'm not sure how it'd influence the widget's data calculations
in this case, if there aren't valid dates to be displayed yet, then the datepicker buttons show a loading spinner.
This PR implements option 4, as it seems like the easier and safer approach; any other widgets that happen to have the same bug and have been undetected should now not trigger the bug either.
Notes:
WidgetHeader
component did expect aloading
prop, which I've passed here. It is used mainly to disable the dropdowns in the widget's settings while the widget is loading.Testing
Tracking
FLAG-343