Skip to content
Open
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 @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## [UNRELEASED]

### 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.
- [#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).
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