Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

should not change input value when changing "defaultValue" attr. #445

Open
jo32 opened this issue Nov 15, 2017 · 1 comment
Open

should not change input value when changing "defaultValue" attr. #445

jo32 opened this issue Nov 15, 2017 · 1 comment

Comments

@jo32
Copy link

jo32 commented Nov 15, 2017

react: https://jsfiddle.net/jo32/85fgabqy/

vs

preact-compat: https://jsfiddle.net/jo32/0gzo34u6/

@gavar
Copy link

gavar commented Sep 20, 2018

I can confirm the issue exists on version 3.18.4

Lines of code affecting it:
https://github.com/developit/preact-compat/blob/3.18.4/src/index.js#L96-L101

You could temporary solve this problem by inverting logic after rendering, by calling this function on the react element:

function fixDefaultValueBug(element, props) {
  const {value, defaultValue} = props;
  if (defaultValue) {
    if (!value && value !== 0) {
      delete element.props.value;
      element.props.defaultValue = defaultValue;
    }
  }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants