Verified Commit 845ded53 authored by alexpott's avatar alexpott
Browse files

Issue #3061148 by vsujeetkumar, Ramya Balasubramanian, raman.b, ankithashetty,...

Issue #3061148 by vsujeetkumar, Ramya Balasubramanian, raman.b, ankithashetty, pmagunia, lauriii, karishmaamin, priyanka.sahni, quietone, Anishnirmal, Akhildev.cs, mitthukumawat, joachim, xjm: a disabled block's admin title gets double-escaped

(cherry picked from commit 50917952)
parent e6df71a6
......@@ -272,11 +272,20 @@ protected function buildBlocksForm() {
$form[$entity_id]['#attributes']['class'][] = 'js-block-placed';
}
$form[$entity_id]['info'] = [
'#plain_text' => $info['status'] ? $info['label'] : $this->t('@label (disabled)', ['@label' => $info['label']]),
'#wrapper_attributes' => [
'class' => ['block'],
],
];
// Ensure that the label is always rendered as plain text. Render
// array #plain_text key is essentially treated same as @ placeholder
// in translatable markup.
if ($info['status']) {
$form[$entity_id]['info']['#plain_text'] = $info['label'];
}
else {
$form[$entity_id]['info']['#markup'] = $this->t('@label (disabled)', ['@label' => $info['label']]);
}
$form[$entity_id]['type'] = [
'#markup' => $info['category'],
];
......
......@@ -588,4 +588,32 @@ public function testBlockUserRoleDelete() {
$this->assertEquals([$role2->id() => $role2->id()], $block->getVisibility()['user_role']['roles']);
}
/**
* Tests block title.
*/
public function testBlockTitle() {
// Create a custom title for the block.
$title = "This block's <b>great!</b>";
// Enable a standard block.
$default_theme = $this->config('system.theme')->get('default');
$edit = [
'id' => 'test',
'region' => 'sidebar_first',
'settings[label]' => $title,
'settings[label_display]' => TRUE,
];
// Set the block to be shown only to authenticated users.
$edit['visibility[user_role][roles][' . RoleInterface::AUTHENTICATED_ID . ']'] = TRUE;
$this->drupalGet('admin/structure/block/add/foo/' . $default_theme);
$this->submitForm($edit, 'Save block');
// Ensure that the title is displayed as plain text.
$elements = $this->xpath('//table/tbody/tr//td[contains(@class, "block")]');
$this->assertEquals($title, $elements[0]->getText());
$this->clickLink('Disable');
$elements = $this->xpath('//table/tbody/tr//td[contains(@class, "block")]');
$this->assertEquals("$title (disabled)", $elements[0]->getText());
}
}
Supports Markdown
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