Closed (duplicate)
Project:
Drupal core
Version:
11.x-dev
Component:
layout_builder.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
10 Apr 2018 at 21:21 UTC
Updated:
27 Jun 2025 at 14:23 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
tedbowComment #3
kducharm commentedComment #4
kducharm commentedModified page title block to use route to populate title during build(), added check in Section rendering loop to change title text to a placeholder. There is some question on what routes should be used to check against so this only appears in layout builder admin, or a better way to identify when the placeholder should be shown.
Created with @tedbow, @geinosky, and @lokapujya
Comment #5
geinosky commentedI concur.
Comment #6
kducharm commentedComment #7
tim.plunkettComment #8
runeasgar commentedTesting latest patch.
Comment #9
runeasgar commented$ curl -l https://www.drupal.org/files/issues/2018-04-13/page-title-block-2959962-4.patch | git apply -v. Succeeded with no errors or warnings.Moving to RTBC.
Comment #10
tedbow@runeasgar thanks for the manual testing!
Settings back to "Needs work" because the patch still needs automated test classes to confirm the fix.
Comment #11
lokapujyaHow should this be tested? A test that checks all Core provided blocks in the layout builder that should have a placeholder?
Comment #12
runeasgar commented@tedbow, given that it's unclear to me when programmatic tests are needed, should I still be moving things to RTBC when I manually test them? I figure if I don't move things to RTBC and they don't need programmatic tests, then someone else has to come along, notice that, and move it to RTBC (which slows the process down for those issues).
Happy to follow whatever process is recommended.
Comment #13
lokapujya@runeasgar, Thank You for testing the issue! Any bugfix in Drupal core needs an automated test. See: Drupal core gates. So, instead of marking RTBC, add the "Needs Tests" tag.
Comment #14
tedbow@runeasgar yep @lokapujya explained it well.
For this bug we will need functional tests for the page title block that include
Comment #15
kducharm commentedComment #16
runeasgar commentedSome day I'll need to learn to write said tests ^_^ seems like low-hanging fruit.
Comment #17
tedbow@runeasgar it's not super hard, especially functional tests.
If you are interested in looking at an example:
\Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testLayoutBuilderUi\Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testLayoutBuilderUiFullViewModeProbably have all the logic that is needed to add the Page title block in a test and confirm that it shows up correct.
You would write a new test method on
\Drupal\Tests\layout_builder\Functional\LayoutBuilderTestcalledtestPageTitleBlock(that is where I would start anyways.Comment #18
runeasgar commentedThanks! I will take a look when I have some time to sit down and learn.
Comment #19
lokapujyaStarted a test.
Comment #20
lokapujyaLet me actually run this and see what happens.
Comment #21
tim.plunkettNice test!
The @var needs updating
= NULLis redundant, please removeThese should use the fully-qualified class name, not include the variable name, and should not have the
|null(if they're set in the constructor, which they are)Hmmm. I really don't like special-casing this code here. If it must live outside the page title block, can you move this to an event subscriber for the
LayoutBuilderEvents::SECTION_COMPONENT_BUILD_RENDER_ARRAYevent?Comment #22
kducharm commented@tim.plunkett for this:
if (strpos($route->getRouteName(), 'layout_builder') !== FALSE) {I saw you mentioned in slack that
if ($route_match->getRouteObject()->getOption('_layout_builder')) {may be a better option, should we do that here?Comment #24
tim.plunkettYes definitely would be better. But my point remains, this is not the place to be inserting per-block logic.
Also, at the Nashville sprint I thought it was suggested that this could use a lazy builder and placeholder, and then it could live inside the block itself. Was that ever explored?
Comment #25
johnwebdev commentedComment #26
johnwebdev commentedAdressed #21.
Not entirely sure if the PageTitleSubscriber should belong in Core like in this uploaded patch, or in layout_builder, ... or somewhere else.
Comment #28
johnwebdev commentedComment #30
johnwebdev commentedAlright, looks like testbot did answer that question for me. Here it is in layout_builder module instead.
Comment #33
tim.plunkettOh this makes me feel so much better to see as an event! It will give people an example of how to manipulate block output specifically for Layout Builder.
We might eventually want to codify this better with an event base class... But that can be for another time
I'm not 100% sure how this relates to the placeholder change. And it doesn't seem to have its own test coverage
$build isn't super reliable, this could be
$block->getPluginId() === 'page_title_block'The "@label - Placeholder..." seems redundant.
Instead I'd suggest
'Placeholder for the "@admin_label" block'with @admin_label corresponding to$block->getPluginDefinition()['admin_label']Also, should it be #title or #markup?
Comment #34
johnwebdev commented1. It kinda does. Actually this issue solves two bugs (I just realised myself), because Page title does not render when placed on LB UI without this part of the code.
So, this part of the test kinda verifies this code change, but not very explicitly:
$assert_session->elementExists('css', '.block-page-title-block');So perhaps it deserves to be solved in another issue which this one may be blocked on, or we write a test for it here, or we can extract that part of the code and let the page title subscriber actually set the title in the context for LB. What do you think?
The Page title block title is set by BlockPageVariant when placed on a region through Block UIs.
Edit: Looks like these problems already been adressed in this issue: https://www.drupal.org/project/drupal/issues/2938129
2. Fixed
3. Fixed
It should be #title, since that is the variable used by the page_title render element.
Comment #35
johnwebdev commentedComment #37
johnwebdev commentedComment #38
tim.plunkettI'd rather move these changes to #2938129: PageTitle block is non-functional when not handled directly by \Drupal\block\Plugin\DisplayVariant\BlockPageVariant (good find, I knew there was an issue but couldn't locate it)
The interdiff changes are great.
Comment #39
johnwebdev commentedAlright, I reverted changes made in PageTitleBlock. Tests remains the same, so no test only reupload.
Comment #40
tim.plunkettNice, this looks really great. One more round of feedback from me.
Why the 90 priority? If it needs to be something other than 0, this needs a comment explaining it.
I know you said that the existing build needs this to be #title. But I would expect that instead of retrieving the existing build, that this could simply set build to a new render array. And if not, the getBuild could move inside the if()
Might as well one-line this
Comment #41
johnwebdev commented#40.1 Fixed.
#40.2 Moved getBuild() within if().
#40.3 Fixed.
Comment #42
tim.plunkettWe discussed the other part of #41.2, and the current approach is needed to keep the rest of the block working.
Comment #43
tim.plunkettIf that passes tests (only reason it wouldn't is the priority change), then I think this is done!
Comment #44
footwearboss commentedEnabled Field Layout, Layout Builder, Layout Discovery modules (not sure what all I need, but that seems comprehensive).
Comment #46
lokapujyaKeeping this up to date.
Comment #47
runeasgar commentedcurl -l https://www.drupal.org/files/issues/2018-05-01/2959962-46.patch | git apply -vHowever, there is an inconsistency.. sort of. Look at the comments placeholder.. it's much more verbose - I know it's for comments. But, "darithijacrogiuucloswojuuaprahinispeliw"? I realize this is some random generation thing, meant to help ensure your content will fit where you're putting it.. but this seems really confusing for an end-user.
How would I know this is the title if I was another end-user coming in to look at this later? I'd have to click the pencil, then configure, in order to see that. Seems pretty bad.
Regardless, setting as RTBC. It's better than the current behavior.
Comment #48
lokapujyaPage title does not render when placed on LB UI when javascript is enabled; The test passes because it doesn't use AJAX. Another patch (event subscriber?) is needed in order to fix the LB UI.
@runeasgar
This random text is the page title override.
Comment #49
alexpottYeah but this is not doing the expected thing of actually displaying the page title. I've tested this manually and it's empty on node/1 even though the page title is the node title.
Also as #48 points out with Javascript enabled the UI doesn't really work either.
Am I missing something?
Comment #50
johnwebdev commented@alexpott
See #34 and #38. This issue only intends to solve the placeholder on LB UI for the Page title.
Comment #51
alexpottOkay well we still have the problem with real-life javascript enabled usage.
Comment #52
tim.plunkettComment #54
savkaviktor16@gmail.com commentedRe-rolled against 8.7.x
Comment #55
dmsmidtManually tested this and it works as expected.
Concerning the real-life JavaScript issue mentioned in #49/#51, this also happens for the core Tabs block.
After refreshing the page the block content is visible until you start rearranging blocks.
If we can agree this is something for a follow up, I'm fine with RTBC-ing this again.
Comment #56
pazhyn commentedApplied manually #54 and it shows the placeholder only after page refreshing. Once you add the block - no placeholder is shown.
Attaching screenshot.
Comment #57
tedbowNeed another re-roll
Comment #58
tim.plunkettLet's postpone this on the new proposed block placeholder API: #2992410: Provide placeholders for empty blocks (for example, an empty Views listing)
Comment #59
tim.plunkettNew approach
Comment #61
tedbowThe fail in #59 is in an seemingly unrelated test method
\Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testNoShortcutLink()The problem is that test method is using the router_test test module to test that
But that test route actually has no title. That is not what that test is actually intending to test.
So it is actually testing that
\shortcut_preprocess_page_titlewill be called for a page that has no title. It seems like that is wrong.For the shortcut case in particular it is testing that add shortcut link is on this page with no title.
but if you actually tested this and actually clicked the add shortcut star in seven theme it would make a shortcut with no title. it would then show up in the shortcut list as a blank line that you could actually click but it would just look like a blank line.
I think we could either
router_test.routing.ymlto have titles. I don't having no titles is actually anything that is actually being intentionally anywhere. Only 2 tests use this test module.Comment #63
tim.plunkettFYI #3029819: Do not allow Page Title block to be placed in Layout Builder until it works properly removed the page title block from the LB block selection list, with an @todo pointing to #2938129: PageTitle block is non-functional when not handled directly by \Drupal\block\Plugin\DisplayVariant\BlockPageVariant to restore it.
Comment #72
lendudeSo this block now no longer exists in the UI? Is that right? So do we postpone this on #2938129: PageTitle block is non-functional when not handled directly by \Drupal\block\Plugin\DisplayVariant\BlockPageVariant ?
Comment #73
smustgrave commentedYea I think this can be marked a duplicate for #2938129: PageTitle block is non-functional when not handled directly by \Drupal\block\Plugin\DisplayVariant\BlockPageVariant believe when that lands this will be fixed. Am leaving all credit too for all the work.