Skip to content

Commit dc1c80a

Browse files
committed
Sort hook selector options alphabetically by name
1 parent 2dd04e5 commit dc1c80a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

admin-dev/themes/new-theme/js/pages/improve/design_positions/hook-module-handler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,12 @@ export default class HookModuleHandler {
105105
const currentValue = this.hookSelector.value;
106106
this.clearHookSelector();
107107

108-
const available = hooks.filter((hook) => !hook.registered);
109-
const registered = hooks.filter((hook) => hook.registered);
108+
// Sort by technical name (case-insensitive) so each group is alphabetical,
109+
// matching the order the option label leads with.
110+
const byName = (a: HookableInfo, b: HookableInfo): number => a.name.localeCompare(b.name, undefined, {sensitivity: 'base'});
111+
112+
const available = hooks.filter((hook) => !hook.registered).sort(byName);
113+
const registered = hooks.filter((hook) => hook.registered).sort(byName);
110114

111115
const buildOption = (hook: HookableInfo): HTMLOptionElement => {
112116
const option = document.createElement('option');

0 commit comments

Comments
 (0)