From 47a64fb930e6f52f4ab037263b157912891a3401 Mon Sep 17 00:00:00 2001 From: philippe Date: Wed, 25 Nov 2026 15:06:40 -0500 Subject: [PATCH 1/2] Keep the pending debounce timer when using number input steppers The stepper called onEvent(), which cleared pendingEvent while a debounce timer was still live. That timer could no longer be cancelled, and each orphan that fired cleared pendingEvent again, so a late timer could write an old value back over what the user had typed. Fix found by Brandon Schabell in #4041. Co-authored-by: Brandon Schabell --- CHANGELOG.md | 1 + .../src/components/Input.tsx | 4 +- .../integration/input/test_number_input.py | 41 +++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9582281a1f..3d0d1ee86b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## [UNRELEASED] ### Fixed +- [#]() Fix `dcc.Input` with `type="number"` and `debounce` sometimes putting back an old value over what the user typed after using the stepper buttons. - [#4167](https://github.com/plotly/dash/pull/4167) `dash-generate-components` no longer crashes when generating an R package from a `package.json` whose `author` is an object or includes a URL, and a missing author email now gets the intended error message. Fixes [#1577](https://github.com/plotly/dash/issues/1577). - [#4169](https://github.com/plotly/dash/pull/4169) Fix the inferred path of a page whose module name contains the pages folder name: `pages/landing_pages.py` no longer gets `/` and `pages/subpages/report.py` no longer gets `/report`. Fixes [#4168](https://github.com/plotly/dash/issues/4168). - [#4174](https://github.com/plotly/dash/pull/4174) Fix `dcc.Graph` discarding earlier layout changes when multiple `Plotly.relayout` calls run before React delivers the updated figure prop. Fixes [#4172](https://github.com/plotly/dash/issues/4172). diff --git a/components/dash-core-components/src/components/Input.tsx b/components/dash-core-components/src/components/Input.tsx index fc92c7b516..01df1e4f2c 100644 --- a/components/dash-core-components/src/components/Input.tsx +++ b/components/dash-core-components/src/components/Input.tsx @@ -208,9 +208,9 @@ function Input({ input.current.value = roundedValue.toString(); setValue(roundedValue.toString()); - onEvent(); + setPropValue(props.value, roundedValue); }, - [step, props.min, props.max, onEvent] + [step, props.min, props.max, props.value, setPropValue] ); useEffect(() => { diff --git a/components/dash-core-components/tests/integration/input/test_number_input.py b/components/dash-core-components/tests/integration/input/test_number_input.py index fdab6f1bf7..88f9dc6c9c 100644 --- a/components/dash-core-components/tests/integration/input/test_number_input.py +++ b/components/dash-core-components/tests/integration/input/test_number_input.py @@ -283,3 +283,44 @@ def update_output(val): dash_dcc.wait_for_text_to_equal("#output", "16") assert dash_dcc.get_logs() == [] + + +def test_inni012_stepper_does_not_orphan_debounce(dash_dcc): + app = Dash(__name__) + app.layout = html.Div( + [dcc.Input(id="input", type="number", debounce=1), html.Div(id="output")] + ) + + @app.callback(Output("output", "children"), Input("input", "value")) + def update(value): + return value + + dash_dcc.start_server(app) + input_elem = dash_dcc.find_element("#input") + increment = dash_dcc.find_element("#input~.dash-stepper-increment") + input_elem.send_keys("100") + dash_dcc.wait_for_text_to_equal("#output", "100") + + # Stepper clicks used to drop the pending debounce timer, so later timers + # fired late and wrote an old value back over what the user had typed. + start = time.time() + + def wait_until(offset): + time.sleep(max(0, start + offset - time.time())) + + increment.click() + wait_until(0.5) + increment.click() + wait_until(1.2) + input_elem.send_keys(Keys.END, "7") + wait_until(1.7) + input_elem.send_keys(Keys.END, "4") + wait_until(2.4) + input_elem.send_keys(Keys.END, "5", Keys.BACKSPACE, Keys.BACKSPACE) + + dash_dcc.wait_for_text_to_equal("#output", "1027") + time.sleep(1.2) + assert input_elem.get_attribute("value") == "1027" + assert dash_dcc.find_element("#output").text == "1027" + + assert dash_dcc.get_logs() == [] From 148e90d5e72e5e197f191111afd910a7fc5724a7 Mon Sep 17 00:00:00 2001 From: philippe Date: Wed, 25 Nov 2026 15:07:03 -0500 Subject: [PATCH 2/2] Add PR number to CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d0d1ee86b..6391992a00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## [UNRELEASED] ### Fixed -- [#]() Fix `dcc.Input` with `type="number"` and `debounce` sometimes putting back an old value over what the user typed after using the stepper buttons. +- [#4197](https://github.com/plotly/dash/pull/4197) Fix `dcc.Input` with `type="number"` and `debounce` sometimes putting back an old value over what the user typed after using the stepper buttons. - [#4167](https://github.com/plotly/dash/pull/4167) `dash-generate-components` no longer crashes when generating an R package from a `package.json` whose `author` is an object or includes a URL, and a missing author email now gets the intended error message. Fixes [#1577](https://github.com/plotly/dash/issues/1577). - [#4169](https://github.com/plotly/dash/pull/4169) Fix the inferred path of a page whose module name contains the pages folder name: `pages/landing_pages.py` no longer gets `/` and `pages/subpages/report.py` no longer gets `/report`. Fixes [#4168](https://github.com/plotly/dash/issues/4168). - [#4174](https://github.com/plotly/dash/pull/4174) Fix `dcc.Graph` discarding earlier layout changes when multiple `Plotly.relayout` calls run before React delivers the updated figure prop. Fixes [#4172](https://github.com/plotly/dash/issues/4172).