Commit c0b346b7 authored by alexpott's avatar alexpott

Issue #2372893 by idebr, Wim Leers: Text editor configuration UI does not...

Issue #2372893 by idebr, Wim Leers: Text editor configuration UI does not update correctly when switching editors
parent 0f93b42d
......@@ -90,7 +90,8 @@ function editor_form_filter_admin_overview_alter(&$form, FormStateInterface $for
* Implements hook_form_BASE_FORM_ID_alter() for 'filter_format_form'.
*/
function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_state) {
if (!$editor = $form_state->get('editor')) {
$editor = $form_state->get('editor');
if ($editor === NULL) {
$format_id = $form_state->getFormObject()->getEntity()->id();
$editor = editor_load($format_id);
$form_state->set('editor', $editor);
......@@ -168,7 +169,8 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s
*/
function editor_form_filter_admin_format_editor_configure($form, FormStateInterface $form_state) {
$editor = $form_state->get('editor');
if ($editor_value = $form_state->getValue(array('editor', 'editor'))) {
$editor_value = $form_state->getValue(array('editor', 'editor'));
if ($editor_value !== NULL) {
if ($editor_value === '') {
$form_state->set('editor', FALSE);
}
......
......@@ -82,6 +82,14 @@ public function testAddEditorToExistingFormat() {
$edit['editor[settings][ponies_too]'] = FALSE;
$this->drupalPostForm(NULL, $edit, t('Save configuration'));
$this->verifyUnicornEditorConfiguration('filtered_html', FALSE);
// Switch back to 'None' and check the Unicorn Editor's settings are gone.
$edit = array(
'editor[editor]' => '',
);
$this->drupalPostAjaxForm(NULL, $edit, 'editor_configure');
$unicorn_setting = $this->xpath('//input[@name="editor[settings][ponies_too]" and @type="checkbox" and @checked]');
$this->assertTrue(count($unicorn_setting) === 0, "Unicorn Editor's settings form is no longer present.");
}
/**
......@@ -125,7 +133,7 @@ protected function selectUnicornEditor() {
$this->assertTrue(((string) $options[0]) === 'None', 'Option 1 in the Text Editor select is "None".');
$this->assertTrue(((string) $options[1]) === 'Unicorn Editor', 'Option 2 in the Text Editor select is "Unicorn Editor".');
$this->assertTrue(((string) $options[0]['selected']) === 'selected', 'Option 1 ("None") is selected.');
// Ensure the none option is selected
// Ensure the none option is selected.
$this->assertNoRaw(t('This option is disabled because no modules that provide a text editor are currently enabled.'), 'Description for select absent that tells users to install a text editor module.');
// Select the "Unicorn Editor" editor and click the "Configure" button.
......
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