Instantiate n_click
of acknowledge button to 0 instead of 1
#176
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.
WHAT'S THE ISSUE
Before this PR we have:
pyro-platform/app/pages/homepage.py
Lines 115 to 118 in 68a6bce
but
pyro-platform/app/callbacks/display_callbacks.py
Lines 470 to 494 in 68a6bce
The intention behind
n_clicks == 0
=>PreventUpdate
seems to be making sure that an alert is not acknowledged when the app loads. But that cannot work given that"acknowledge-button"
is instantiated to haven_clicks = 1
.WHY DOES IT MATTER IF WE HAVE
prevent_initial_call=True
anyways?Preventing acknowledgment on load is indeed already covered by
prevent_initial_call=True
.However,
prevent_initial_call=True
does not cover accidental runs on redirect.We have:
pyro-platform/app/layouts/main_layout.py
Line 31 in 68a6bce
which implies upon url redirects Dash (/the underlying React engine) attempts to catch redirects triggered within the app and modify pages minimally instead of fully reloading a page.
As I understand the Dash/React lifecycle, this implies redirects triggered within the app do not count as page reloads =>
prevent_initial_call=True
does not apply to those page reloads=> Dash re-runs all callbacks (or at least those for which the inputs or states may have changed).
=> At least if the acknowledge button is modified by the redirect (e.g., text translated from #173), it's reinstantiated to
n_clicks = 1
, the safeguard in the callback does not apply, and the error is acknowledged.