Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Validation messages for errors in the block configuration forms of do not get displayed because of #2897377: $form['#attributes']['data-drupal-selector'] is set to a random value so can't be used for its intended purpose.
Proposed resolution
Set the $form['#id']
explicitly so the messages will be displayed.
Remaining tasks
Review
User interface changes
the error messages will show.
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#45 | 2968110-45.patch | 8.15 KB | tedbow |
#45 | interdiff-44-45.txt | 1.73 KB | tedbow |
#44 | 2968110-43.patch | 8.22 KB | tedbow |
#44 | interdiff-reroll-44.txt | 2.3 KB | tedbow |
#41 | interdiff-39-40.patch | 885 bytes | tedbow |
Comments
Comment #2
tedbowHere is a patch
\Drupal\Core\Ajax\AjaxFormHelperTrait::ajaxSubmit
AjaxFormHelperTrait
?\Drupal\Tests\layout_builder\Functional\LayoutBuilderTest
to a Javascript test to be able to test this?Comment #3
tedbowUpdateBlockForm
also was not showing validation messages so I moved the fix logic up to\Drupal\layout_builder\Form\ConfigureBlockFormBase
So it somehow seems like a form #weight bug but I am probably missing something
So I updated
\Drupal\Core\Ajax\AjaxFormHelperTrait
to actually movestatus_messages
to the beginning of the array.I am not sure why I had to update that but couldn't figure out why it wasn't ordering correctly.
\Drupal\settings_tray\Block\BlockEntitySettingTrayForm
doesn't have this problem but I can't see the difference.Comment #4
bkosborneThis works well for me, thanks for the patch. Would RTBC but I guess still needs a test.
I also looked into the weight issue and couldn't figure out the problem. The form is rendered via \Drupal::service('renderer')->renderRoot() before being inserted into the AJAX response. Maybe in other circumstances, the form is processed further to do something with the weights which is skipped in this scenario?
Comment #6
tim.plunkettNW for tests
Comment #7
tedbowHere is a patch with tests:
InlineBlockTestBase
. We should probably have aLayoutBuilderTestBase
but I am going to look at #2924201: Resolve random failure in LayoutBuilderTest so that it can be added to HEAD now to see if we can finish that up.Comment #9
tedbowForgot
@group
😜Comment #11
tedbowWhoops #9 was not clean. Reuploading
Just running the 1 test.
Comment #13
tedbowI am not sure why this is failing. Extending the wait for the element that is causing the fail. But I don't think that will help.
Comment #15
tedbowsince I can't get it to fail locally I putting some debug messages to see if the dialog is actually closed or not
Comment #17
tedbowHmm. I don't understand why
waitForElement()
didn't return NULL here again.Comment #19
tedbowWhat? Even though the required title field is still to "" it the off-canvas dialog is still being closed.
Wonder if it could be problem that contextual link in the test is actually not opening in the off-canvas dialog?
Changing the assert to actually look for the elements in the off-canvas dialog.
Comment #20
tedbowLeaving these changes in because it is a more explicit assertion
I have feeling this is what actually fixed the test. I ran into this in #2957425: Allow the inline creation of non-reusable Custom Blocks in the layout builder when clicking on the link was not the same for some reason as using
drupalGet()
Comment #21
tim.plunkettI've seen this copied around a couple times now. Is this the actual fix?
Or is this the fix? I feel like we should be clear here, and I don't understand this change
Comment #22
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedPromoting to major as this is needed for WCAG level A - see SC 3.3.1 Error Identification.
Where will the errors be displayed - in the off-canvas dialog?
Comment #23
tedbowre #21
1) is the actual fix to get the messages to show.
Without 2) the messages will show up at the bottom of the form. Not sure why. My guess is the sorting already has happened at this point so simply setting the weight will not work.
Comment #24
tedbowComment #25
tim.plunkettAny reason not to use
array_unshift()
instead?Can this whole comment be made an @todo instead of just the last line, and be sure to indent subsequent comment lines two more spaces
Also NW for a reroll since the drupalci.yml changes conflict and should be removed anyway.
Comment #26
tedbowre #25
1. fixed
2. fixed
And
We don't actually need this if we have proper waits. the test module has been removed.
@see #3020142: Test module no_transitions_css has invalid hook_page_attachments
I don't think we need the work around this method provides. @tim.plunkett ran into this same problem in another test and figure out it was problem with a link or button being out of the viewport. I copied this
\Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockTestBase::assertSaveLayout
but only needed there because adding more inline block pushes the link out of the viewport. This test is only adding 1 block so shouldn't be a problem. Will confirm with a 30x patch.Comment #27
tim.plunkettJust for readability, can this be changed to
This is no longer used in the patch, it can be removed.
Comment #28
tedbowfixed #27
Comment #29
tim.plunkettThanks!
Comment #31
tedbowLooks like random fail because we weren't waiting for canvas to close.
Comment #33
Kristen PolDoes this need manual testing?
Comment #34
tedbow@Kristen Pol sure! just used the layout and add/configure any block. remove the title(or other required field). You should see the validation error message in the off-canvas dialog.
The last patch failed here is another x30 patch
Comment #35
ariane CreditAttribution: ariane commentedPatch 2968110-34.patch in #34 works well with core version 8.6.7
Thanks @tedbow!
Comment #37
tedbow#36 is because aborted a test. I mean to retest the x30 patch from #34 but selected the wrong 1 twice.
Re-queued the x30 times patch a few times to be sure we got the random fail.
Comment #39
tedbowok so now the x30 test that was passing is now failing
All failing right here when trying to save the layout.
with
This is a common cause of random failures 😟
And it seems to not happen locally much. So something is happening that is making a link not clickable because another element would get the click.
My theory is something monetarily in the way and the time is different depending on something in the state of Drupalci, so it is very hard to fix.
What if we just tried a number of times click the link. Like we do with visibility in
\Drupal\FunctionalJavascriptTests\JSWebAssert::waitForElementVisible()
.Here is a x30 patch with
clickElementWhenClickable()
. which should be moved to a trait if this a solution.Comment #41
tedbowyay! A totally different random error in #39.
While #34 seem to fail about 1/3 of the time #39 failed 1 out of 30.
This
This is where it failed.
This the same random error I had to put a very strange fix in for in
\Drupal\Tests\layout_builder\FunctionalJavascript\InlineBlockTestBase::assertSaveLayout()
@tim.plunkett ran into this same problem recently and solved it my just reloading the page.
Trying that here
Comment #43
tedbow#42 set it to Needs Work because use a ".patch" extension for the interdiff file. Whoops
Comment #44
tedbowOk the patches before had unrelated changes
Comment #45
tedbow$form['#sorted'] = FALSE;
Comment #46
tim.plunkettThis is such a clean fix now. Nice!
Note that this workaround also exists in Settings Tray module
Comment #48
xjmCommitted to 8.7.x. Thanks!
Comment #49
tedbow🎉 thanks @xjm and all those you worked on this!
Comment #51
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedfixing accessibility tag