Problem/Motivation

Visit: /admin/config/development/configuration/single/export

Ensure that the Configuration type is Simple configuration, change it to this value if not.

The first option in Configuration name is not easy to export because the form is submitted on a change to this field.

If you switch Configuration type to a different value then the Configuration name field has a default option of '- Select -' which prompts the user to make a choice.

Proposed resolution

Introduce a default option for the field Configuration name of '- Select -' for the Simple configuration.

Remaining tasks

Provide patch to fix the issue

Write a test to prevent regression.

CommentFileSizeAuthor
#50 interdiff_49-50.txt2.98 KBraman.b
#50 2577219-50.patch11.33 KBraman.b
#50 2577219-50-test-only.patch3.36 KBraman.b
#49 interdiff_48-49.txt1.08 KBraman.b
#49 2577219-49.patch7.97 KBraman.b
#48 interdiff_47-48.txt1.24 KBraman.b
#48 2577219-48.patch6.57 KBraman.b
#47 interdiff_40-47.txt5.1 KBraman.b
#47 2577219-47.patch6.38 KBraman.b
#43 Clip.mov782.52 KBpartyka
#40 2577219-40.patch2.73 KBlarowlan
#40 2577219-interdiff.txt2.15 KBlarowlan
#33 interdiff_28-33.txt1.47 KBridhimaabrol24
#33 2577219-33-test-only-patch.patch972 bytesridhimaabrol24
#33 2577219-33.patch3.94 KBridhimaabrol24
#29 Screen Shot 2020-07-22 at 11.04.22 AM.png69.92 KBKristen Pol
#29 Screen Shot 2020-07-22 at 11.04.13 AM.png101.72 KBKristen Pol
#29 Screen Shot 2020-07-22 at 11.04.05 AM.png70.55 KBKristen Pol
#28 interdiff_26-28.txt721 bytesridhimaabrol24
#28 2577219-28.patch3.64 KBridhimaabrol24
#26 blank-text-field-for-select.png98.58 KBridhimaabrol24
#26 some-other-config.png118.55 KBridhimaabrol24
#26 select-option.png411.74 KBridhimaabrol24
#26 interdiff_22-26.txt2 KBridhimaabrol24
#26 2577219-26.patch3.64 KBridhimaabrol24
#24 Screen Shot 2020-07-21 at 11.21.30 PM.png73.63 KBKristen Pol
#24 Screen Shot 2020-07-21 at 11.21.07 PM.png103.41 KBKristen Pol
#24 Screen Shot 2020-07-21 at 11.20.56 PM.png127.73 KBKristen Pol
#22 interdiff_20-22.txt728 bytesridhimaabrol24
#22 2577219-22.patch1.79 KBridhimaabrol24
#20 2577219-20.patch973 bytesHardik_Patel_12
#5 single_item-2577219-5-testonly.patch880 bytesnlisgo
#4 after_fix.png82 KBnlisgo
#4 before_fix.png94.73 KBnlisgo
#3 single_item-2577219-3.patch1.7 KBnlisgo
#2 single_item-2577219-2-testonly.patch880 bytesnlisgo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nlisgo created an issue. See original summary.

nlisgo’s picture

nlisgo’s picture

Status: Active » Needs review
FileSize
1.7 KB
nlisgo’s picture

Issue summary: View changes
FileSize
94.73 KB
82 KB

Before:

After:

nlisgo’s picture

FileSize
880 bytes

Uploading a test only patch, this is expected to fail. The test is included with a fix in #3.

Status: Needs review » Needs work

The last submitted patch, 5: single_item-2577219-5-testonly.patch, failed testing.

nlisgo’s picture

Status: Needs work » Needs review

Patch to review is #3. The patch in #5 is a 'test only' patch.

Status: Needs review » Needs work

The last submitted patch, 5: single_item-2577219-5-testonly.patch, failed testing.

nlisgo’s picture

Status: Needs work » Needs review
nlisgo’s picture

Would there be any interest in making this UI work without JS. My justification for suggesting it is because I think it should be quite easily achievable and also while we do not have the ability to write tests for javascript it would make this interface more testable. Thoughts? If there is support, I would open a different issue for it.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Kristen Pol’s picture

Version: 8.9.x-dev » 9.1.x-dev
Status: Needs review » Needs work
Issue tags: +Bug Smash Initiative, +Needs reroll

Needs reroll for 9.1.x as test code moved to core/modules/config/tests/src/Functional/ConfigExportUITest.php.

Hardik_Patel_12’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
973 bytes

Re-rolled against 9.1.x. Kindly review a patch.

Status: Needs review » Needs work

The last submitted patch, 20: 2577219-20.patch, failed testing. View results

ridhimaabrol24’s picture

Status: Needs work » Needs review
FileSize
1.79 KB
728 bytes

Patch #20 is a "test-only-patch". The actual fix is missing. Updating the patch here. Please review!

idebr’s picture

Kristen Pol’s picture

Thanks for the update.

When manually testing and going from a chosen configuration to the select option, it then shows false in the Here is your configuration: section. See screenshots.

Kristen Pol’s picture

And note the similar issue from @idebr: #2622468: Export single simple configuration name has no empty value, resulting in confusing UI

You can take a look at the patch there as well. One of these issues will need to be closed out but since this issue is slightly older and is being updated now, IMO it should be the other issue. Then those users should be noted here so they can get issue credit.

ridhimaabrol24’s picture

Fixing the bug in #24. Tested it manually as well. It now shows blank in the config text area on choosing 'Select'.
Also attaching the screenshots for reference.
Please review!

Status: Needs review » Needs work

The last submitted patch, 26: 2577219-26.patch, failed testing. View results

ridhimaabrol24’s picture

Status: Needs work » Needs review
FileSize
3.64 KB
721 bytes

Fixing failed test.

Kristen Pol’s picture

Thanks for the update.

1) Manually tested and it worked as expected. Select option is available and chosen by default, switching to different configuration option shows the config for that, and switching back to select after that shows nothing in the Here is your configuration: box. See screenshots.

2) This still needs a proper code review and a comparison with #2622468: Export single simple configuration name has no empty value, resulting in confusing UI.

3) If this one is good-to-go, then the other issue should be closed out and all those issue participants should be added to this issue for issue credit.

Default:

Choosing an option:

Switching back to select:

partyka’s picture

I’ll review.

larowlan’s picture

Status: Needs review » Needs work

Can we get a test-only patch here that fails as expected, the one above passed - just to demonstrate this is fixed.

Can we use the '#empty_value' and '#empty_option' properties of select fields instead of adding the empty item to the array.

That will mean we don't need to think about this at all and can remove the existing code that sets the '' option.

partyka’s picture

Ok -- waiting for @larowlan's recommendation to be implemented before a complete review. However, I will second @Kirsten Pol's statement that it works as expected.

ridhimaabrol24’s picture

Adding a test only patch.
Used '#empty_option' of select field.
Please review the same.
Thanks

Status: Needs review » Needs work

The last submitted patch, 33: 2577219-33-test-only-patch.patch, failed testing. View results

larowlan’s picture

Status: Needs work » Needs review
+++ b/core/modules/config/src/Form/ConfigSingleExportForm.php
@@ -141,18 +142,26 @@ public function updateConfigurationType($form, FormStateInterface $form_state) {
-    // Determine the full config name for the selected config entity.
-    if ($form_state->getValue('config_type') !== 'system.simple') {
-      $definition = $this->entityTypeManager->getDefinition($form_state->getValue('config_type'));
-      $name = $definition->getConfigPrefix() . '.' . $form_state->getValue('config_name');
+    $config_type = $form_state->getValue('config_type');
+    $config_name = $form_state->getValue('config_name');
+    if (!empty($config_name)) {
+      // Determine the full config name for the selected config entity.
+      if ($config_type !== 'system.simple') {
+        $definition = $this->entityTypeManager->getDefinition($config_type);
+        $name = $definition->getConfigPrefix() . '.' . $config_name;
+      }
+      // The config name is used directly for simple configuration.
+      else {
+        $name = $config_name;
+      }
+      // Read the raw data for this config name, encode it, and display it.
+      $form['export']['#value'] = Yaml::encode($this->configStorage->read($name));
+      $form['export']['#description'] = $this->t('Filename: %name', ['%name' => $name . '.yml']);
     }
-    // The config name is used directly for simple configuration.
     else {
-      $name = $form_state->getValue('config_name');
+      $form['export']['#value'] = '';
+      $form['export']['#description'] = '';
     }
-    // Read the raw data for this config name, encode it, and display it.
-    $form['export']['#value'] = Yaml::encode($this->configStorage->read($name));
-    $form['export']['#description'] = $this->t('Filename: %name', ['%name' => $name . '.yml']);

with the new #empty option approach - are all these changes still needed? they may not be

ridhimaabrol24’s picture

@larowlan, yes these changes are required to fix the "false" value that was appearing in the configuration text area as mentioned by @Kristen Pol in #24.
These conditions are catering to that fix.

partyka’s picture

@larowlan, I'm able to confirm that @ridhimaabrol24's statement about that code being required to fix #24 prevents "false" from appearing in the area, and everything else about config export is working

partyka’s picture

Status: Needs review » Needs work

However, i've uncovered something new. If you happen to switch to any other configuration type (that is, something that is not Simple Configuration), and then switch back to Simple Configuration, the "-- Select --" option no longer appears. I was attempting to provide a screenshot, but I'm out of review time for the day.

Please let me know if you're having difficulty reproducing and I'll provide screenshots later. Thanks!

ridhimaabrol24’s picture

Hi @larowlan
The options are being overriden in the callback function "findConfiguration". Hence empty_option doesn't work there. We need to include the select in the callback itself. Hence patch #28 works perfectly for that case. Please let me know your views on this and how can we proceed further.
Thanks

larowlan’s picture

Status: Needs work » Needs review
FileSize
2.15 KB
2.73 KB

Those changes are out of scope, the attached interdiff is much simpler, and also works.

partyka’s picture

@larowlan, what changes are out of scope? Having "-- select --" be added back if the user switches to a different config type, and then back to "Simple Configuration"?

larowlan’s picture

@partyka the changes I highlighted in #35 - #40 shows they're not required

partyka’s picture

FileSize
782.52 KB

@larowlan, I may not have communicated my observation well. I've taken a screen recording, and you can see it in the attached screen recording. I have applied your latest patch and I'm still seeing the "-- Select --" disappear after switching to a different configuration type.

longwave’s picture

Status: Needs review » Needs work

Agree with #38/43, the empty option is there on page load but removed after an Ajax callback.

I tried to trace what is going on but got lost in the rendering system. I think what is happening is that the Select::processSelect() process callback (which is responsible for inserting the empty option) is not being called after ConfigSingleExportForm::updateConfigurationType() returns the element for update. I guess this might be a wider bug in Ajax select elements, maybe the empty option needs to be added in a prerender callback instead?

larowlan’s picture

Issue tags: +Needs tests

Ok, that also sounds like the added test isn't covering what we need it to.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

raman.b’s picture

Component: config.module » render system
FileSize
6.38 KB
5.1 KB

Agree with #44. This seems like a larger issue with select elements having AJAX callbacks.

As suggested, I've moved the logic to add the empty option from Select::processSelect() to a pre render callback Select::preRenderSelect(). I also had to adjust the validation a bit to make it work

Let's see if this breaks anything

raman.b’s picture

Looks like we can't just move it. We need this at both places or maybe I'm missing something here

raman.b’s picture

raman.b’s picture

Title: Single item configuration export form config_name does not have "- Select -" as it's first option » Select's #empty_option gets removed on ajax callback
Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
3.36 KB
11.33 KB
2.98 KB

Adding a quick test to demonstrate the issue

raman.b’s picture

Issue summary: View changes

The last submitted patch, 50: 2577219-50-test-only.patch, failed testing. View results

longwave’s picture

Thanks for working on this and well done on tracing and fixing this - you have more patience with debugging the Ajax render system than I do!

However, I feel like the original issue here has been hijacked and there is significant scope creep. Core committers tend not to like fixing two separate problems in the same issue where possible. Can you spin off a child issue where we can fix the Ajax issue on its own first, postpone this issue, wait for the child issue to be committed first, and then we can come back here and fix the original issue with the configuration export form?

raman.b’s picture

Title: Select's #empty_option gets removed on ajax callback » Single item configuration export form config_name does not have "- Select -" as it's first option
Issue summary: View changes
Status: Needs review » Postponed

Makes complete sense. Created the new issue here #3180011: Select's #empty_option gets removed on ajax callback

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.