diff --git a/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php b/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php index 1b611471c043cca89d14084a6fbd357975843451..0c35e82c051b40c81f893263f4c3c1f8aac16fca 100644 --- a/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php +++ b/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php @@ -59,7 +59,7 @@ public function autocomplete(Request $request) { $matches = array(); foreach ($this->blockManager->getCategories() as $category) { if (stripos($category, $typed_category) === 0) { - $matches[$category] = String::checkPlain($category); + $matches[] = array('value' => $category, 'label' => String::checkPlain($category)); } } return new JsonResponse($matches); diff --git a/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php b/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php index 29d75d0ff8fc039bc5f8dfeab5ef59eb747ad6e4..26bd6b9151da83b07b7a510323bb914c06dd3acd 100644 --- a/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php @@ -59,8 +59,8 @@ public function setUp() { */ public function testAutocompleteSuggestions($string, $suggestions) { $suggestions = array_map(function ($suggestion) { - return String::checkPlain($suggestion); - }, array_combine($suggestions, $suggestions)); + return array('value' => $suggestion, 'label' => String::checkPlain($suggestion)); + }, $suggestions); $result = $this->autocompleteController->autocomplete(new Request(array('q' => $string))); $this->assertSame($suggestions, json_decode($result->getContent(), TRUE)); }