I have a dash app with two callbacks, one that modifies the page’s layout and one that updates the URL query params. (The query params pre-populate some inputs.) Both callbacks are activated at the click of the same button.
When I click the button, the layout is updated correctly. For some reason, however, the callback updating the query params does not work.
Here is what the app’s code looks like:
import dash
from flask import Flask
@dash.callback(
output=Output("url", "search"),
inputs=[Input(ID_BUTTON_SUBMIT, "n_clicks")],
)
def update_query(*args) -> str:
return "?some=param"
@dash.callback(
output=[
# some outputs
],
inputs=[Input(ID_BUTTON_SUBMIT, "n_clicks")],
state=[
# some state
],
prevent_initial_call=True,
)
def render_page(*args) -> Tuple[Optional[Div], ...]:
return (
html.Div(),
# ...
)
server = Flask(__name__)
app = dash.Dash(
app_name,
server=server ,
meta_tags=[{"name": "viewport", "content": "width=device-width"}],
suppress_callback_exceptions=True,
url_base_pathname="/",
)
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True)
I tried to restructure the code and move the callbacks to different modules, but that actually made things worse (the layout callback stopped working as well). What am I doing wrong?