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.
Comment | File | Size | Author |
---|---|---|---|
#50 | interdiff_49-50.txt | 2.98 KB | raman.b |
#50 | 2577219-50.patch | 11.33 KB | raman.b |
#50 | 2577219-50-test-only.patch | 3.36 KB | raman.b |
#49 | interdiff_48-49.txt | 1.08 KB | raman.b |
#49 | 2577219-49.patch | 7.97 KB | raman.b |
Comments
Comment #2
nlisgo CreditAttribution: nlisgo commentedComment #3
nlisgo CreditAttribution: nlisgo commentedComment #4
nlisgo CreditAttribution: nlisgo commentedBefore:
After:
Comment #5
nlisgo CreditAttribution: nlisgo commentedUploading a test only patch, this is expected to fail. The test is included with a fix in #3.
Comment #7
nlisgo CreditAttribution: nlisgo commentedPatch to review is #3. The patch in #5 is a 'test only' patch.
Comment #9
nlisgo CreditAttribution: nlisgo commentedComment #10
nlisgo CreditAttribution: nlisgo commentedWould 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.
Comment #19
Kristen PolNeeds reroll for 9.1.x as test code moved to
core/modules/config/tests/src/Functional/ConfigExportUITest.php
.Comment #20
Hardik_Patel_12 CreditAttribution: Hardik_Patel_12 at QED42 for Drupal India Association commentedRe-rolled against 9.1.x. Kindly review a patch.
Comment #22
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedPatch #20 is a "test-only-patch". The actual fix is missing. Updating the patch here. Please review!
Comment #23
idebr CreditAttribution: idebr at iO commentedComment #24
Kristen PolThanks for the update.
When manually testing and going from a chosen configuration to the select option, it then shows
false
in theHere is your configuration:
section. See screenshots.Comment #25
Kristen PolAnd 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.
Comment #26
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedFixing 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!
Comment #28
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedFixing failed test.
Comment #29
Kristen PolThanks 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:
Comment #30
partyka CreditAttribution: partyka at Argonne National Laboratory commentedI’ll review.
Comment #31
larowlanCan 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.
Comment #32
partyka CreditAttribution: partyka at Argonne National Laboratory commentedOk -- 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.
Comment #33
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedAdding a test only patch.
Used '#empty_option' of select field.
Please review the same.
Thanks
Comment #35
larowlanwith the new #empty option approach - are all these changes still needed? they may not be
Comment #36
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commented@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.
Comment #37
partyka CreditAttribution: partyka at Argonne National Laboratory commented@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
Comment #38
partyka CreditAttribution: partyka at Argonne National Laboratory commentedHowever, 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!
Comment #39
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedHi @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
Comment #40
larowlanThose changes are out of scope, the attached interdiff is much simpler, and also works.
Comment #41
partyka CreditAttribution: partyka at Argonne National Laboratory commented@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"?
Comment #42
larowlan@partyka the changes I highlighted in #35 - #40 shows they're not required
Comment #43
partyka CreditAttribution: partyka at Argonne National Laboratory commented@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.
Comment #44
longwaveAgree 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 afterConfigSingleExportForm::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?Comment #45
larowlanOk, that also sounds like the added test isn't covering what we need it to.
Comment #47
raman.b CreditAttribution: raman.b at OpenSense Labs commentedAgree 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 callbackSelect::preRenderSelect()
. I also had to adjust the validation a bit to make it workLet's see if this breaks anything
Comment #48
raman.b CreditAttribution: raman.b at OpenSense Labs commentedLooks like we can't just move it. We need this at both places or maybe I'm missing something here
Comment #49
raman.b CreditAttribution: raman.b at OpenSense Labs commentedComment #50
raman.b CreditAttribution: raman.b at OpenSense Labs commentedAdding a quick test to demonstrate the issue
Comment #51
raman.b CreditAttribution: raman.b at OpenSense Labs commentedComment #53
longwaveThanks 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?
Comment #54
raman.b CreditAttribution: raman.b at OpenSense Labs commentedMakes complete sense. Created the new issue here #3180011: Select's #empty_option gets removed on ajax callback
Comment #56
cilefen CreditAttribution: cilefen at Institute for Advanced Study commented