Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Control component model values with 'debounce' defined are not resetting on actions.reset #884

@lstuartfry

Description

@lstuartfry

The Problem

When building a Control component and defining a 'debounce' prop, that component's model value is not reset when calling actions.reset on the form model. This is most likely related to the changes released with version 1.11.2, in relation to the 'debounce' prop. It looks like this change was added in relation to issue #799. The problem is, even if the debounced actions.change action has already finished updating the form, it will run again immediately after the component is unmounted.

Steps to Reproduce

Simply mount a form with a single Control component, and define a 'debounce' prop on the component. In componentWillUnmount, call an actions.reset on the form. Enter any value in the field, and unmount the form. First, the actions.reset call occurs, followed immediately by an actions.change call that restores the model to it's previous value.

Expected Behavior

The model's value will be restored to it's original value, defined wherever you chose to write its initialFormState.

Actual Behavior

The model is first reset to it's initial value, then restored to whichever value it held when the last debounced actions.change call was made.

Reproducible Code Example

(please fork from this CodePen template)
My CodePen example implements a simple button that switches between two forms. Each form calls actions.reset on its respective model on componentWillUnmount.
Please note - when I revert to version 1.11.1 or earlier, this problem does not occur. Also, I'd be more than happy to take a look at the source code and start working on a solution that satisfies both issue #799 and this new unexpected behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions