The theme autocomplete list on the help topic editing form doesn't seem to be ordered in any way.

The module and topic autocompletes are in alphabetical order by human name, which is good, but the theme list seems to be random.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon created an issue. See original summary.

Amber Himes Matz’s picture

Assigned: Unassigned » Amber Himes Matz
jhodgdon’s picture

Just a note that there is a test for the theme autocompletes in tests/src/Functional/HelpTopicAdminTest in method testAutocomplete(), and if you fix this bug, you may need to modify the order of expected return values in the tests.

Hm. It looks like both the module and topic autocomplete lists are alphabetical by machine name. Which is probably OK to leave as they are?

Amber Himes Matz’s picture

Hey @jhodgdon, should I hold off on attempting this until the dust settles on #2926651?

jhodgdon’s picture

No, I think it's fine to work on this now. It shouldn't conflict or intersect. Thanks!

Amber Himes Matz’s picture

Finally getting around to this!

But I want to make sure I'm looking in the right place. Are we talking about the "Theme dependencies" field? Because on the topic editing form, in the Dependencies fieldset, the Theme dependencies autocomplete looks like it's returning an alphabetically ordered list.

See attached screenshot. Am I in the right place @jhodgdon?

jhodgdon’s picture

Yes, that's it. I wonder if it is always alphabetical, or just sometimes alphabetical? Certainly when I created this issue, I thought it wasn't alphabetical.

So I think we still need to add a line or two of code to make sure it is alphabetical. Just sort the array of possibilities returned by the autocomplete controller's theme method.

Amber Himes Matz’s picture

Ok, here's a patch which should sort the theme autocomplete results alphabetically.

Amber Himes Matz’s picture

Assigned: Amber Himes Matz » Unassigned
Status: Active » Needs review
andypost’s picture

I'm not sure this is right way and we need to reconsider mapping internals to UI

when we do search in
- topics (id,label) we use sort('label') and results already ordered by Human name of topic
- modules - returned by weight in system
- themes are ordered ... \Drupal\Core\Extension\ExtensionDiscovery::scan() so comment tells

// Sort the discovered extensions by their originating directories.

So surely we have no weight system then label is best choice to sort themes

PS: do we include profiles into list of modules? or separate thing? cos extension system finally has api

+++ b/src/Controller/AutocompleteController.php
@@ -173,6 +173,8 @@ class AutocompleteController extends ControllerBase {
+    ksort($matches);

that happens in \Drupal\help_topics\Controller\AutocompleteController::themeAutocomplete()

andypost’s picture

Here's my vision, we need sort before search to return more narrow results

andypost’s picture

Issue tags: +Needs tests

And needs coverage by kernel test or kinda

andypost’s picture

Status: Needs review » Closed (duplicate)
Issue tags: -Needs tests

Getting modules & themes with ordering has patch in #2943920-3: Use newer API for getting module info