Skip to content

[BUG] Layout Hooks interfere with Persistence #3370

Description

@Aaron-Wrote-This

Context
Python 3.13.5

dash                 3.1.1

Bug

When a layout hook is enabled, persistence doesn't function. The values are saved to the browser, but they're not used upon refresh.

Expected behavior

Upon reloading the page the input value is persisted, so it has the same value as before reloading.

Screenshots

Image

from dash import hooks, dcc, html, callback, Input, Output, Dash

app = Dash()

app.layout = html.Div([
    dcc.Input(
        id='input-number',
        persistence=True, persistence_type='local'
    ),
    html.Div(id='output-div')
])

@callback(
    Output('output-div', 'children'),
    Input('input-number', 'value')
)
def update_output(value):
    return f'The input is {value}'

# Comment out to "fix" persistence
@hooks.layout()
def update_layout(layout):
    return [html.Div("New layout content"), layout]
# Comment out to "fix" persistence

if __name__ == '__main__':
    app.run(debug=True)

Metadata

Metadata

Assignees

Labels

P1needed for current cyclebugsomething brokenregressionthis used to work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions