Commit 99e21343 authored by Jérome Perrin's avatar Jérome Perrin

core: set state in value during gadget_editor.getContent

To be consistent with what the underlying gadget does.

This is needed if we want this snippet to empty the editor:

// user type something in editor
gadget.getContent().then(content => {gadget.changeState({value: ''})})

otherwise the state's value is considered to be still "" and this
changeState does nothing.
parent 73096e57
......@@ -184,6 +184,10 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
})
.push(function (editor_gadget) {
return editor_gadget.getContent.apply(editor_gadget, argument_list);
}).push(function (content) {
// change state in place, like embedded editor does.
gadget.state.value = content[gadget.state.key];
return content;
})
.push(unlockGadgetInQueue(gadget), unlockGadgetInFailedQueue(gadget));
/*
......@@ -200,7 +204,7 @@ lockGadgetInQueue, unlockGadgetInQueue, unlockGadgetInFailedQueue*/
} else if (this.state.editable &&
(this.state.editor === 'text_area')) {
result = {};
result[this.state.key] = this.element.querySelector('textarea').value;
result[this.state.key] = this.state.value = this.element.querySelector('textarea').value;
return result;
}
return {};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment