Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- [#4118](https://github.com/plotly/dash/pull/4118) The JupyterLab extension now ships prebuilt, so JupyterLab 3 and 4 load it without asking for a rebuild. JupyterLab 2 is no longer supported. Fixes [#3828](https://github.com/plotly/dash/issues/3828).

### Fixed
- [#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.
- [#4102](https://github.com/plotly/dash/pull/4102) Fix `dcc.Graph` zoom, pan and other edits being reset by a new figure or a `Patch` while `uirevision` is unchanged, a regression from #3882. Fixes [#4093](https://github.com/plotly/dash/issues/4093).
- [#4103](https://github.com/plotly/dash/pull/4103) Speed up components that use `dashChildrenUpdate` (`dcc.Tabs` and others): unrelated paths are now rejected before any allocation on each store update. Addresses [#4032](https://github.com/plotly/dash/issues/4032).
- [#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).
Expand Down
4 changes: 2 additions & 2 deletions components/dash-core-components/src/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() == []
Loading