MDL-75969 behat: Allow the editor field to request a save
Some editors do not immediately store their content to the textarea they represent and only do so when the form is submitted or they are requested to. This change adds to the existing API to allow an (optional) `store_current_value` function to be defined for the editor type so that it can use the JavaScript API to persist any current content to the editor.
This commit is contained in:
@@ -60,6 +60,23 @@ class behat_form_editor extends behat_form_textarea {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current value of the select element.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_value(): string {
|
||||
if ($this->running_javascript()) {
|
||||
// Give any listening editors a chance to persist the value to the textarea.
|
||||
// Some editors only do this on form submission or similar events.
|
||||
behat_base::execute_in_matching_contexts('editor', 'store_current_value', [
|
||||
$this->field->getAttribute('id'),
|
||||
]);
|
||||
}
|
||||
|
||||
return parent::get_value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all the text in the form field.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user