Skip to content

Commit 5c737b9

Browse files
authored
Don't detach value from defaultValue for submit/reset inputs (#7197)
1 parent d2ff462 commit 5c737b9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/renderers/dom/client/wrappers/ReactDOMInput.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,20 @@ var ReactDOMInput = {
216216
},
217217

218218
postMountWrapper: function(inst) {
219+
var props = inst._currentElement.props;
220+
219221
// This is in postMount because we need access to the DOM node, which is not
220222
// available until after the component has mounted.
221223
var node = ReactDOMComponentTree.getNodeFromInstance(inst);
222-
node.value = node.value; // Detach value from defaultValue
224+
225+
// Detach value from defaultValue. We won't do anything if we're working on
226+
// submit or reset inputs as those values & defaultValues are linked. They
227+
// are not resetable nodes so this operation doesn't matter and actually
228+
// removes browser-default values (eg "Submit Query") when no value is
229+
// provided.
230+
if (props.type !== 'submit' && props.type !== 'reset') {
231+
node.value = node.value;
232+
}
223233

224234
// Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
225235
// this is needed to work around a chrome bug where setting defaultChecked

0 commit comments

Comments
 (0)