Skip to content

fix: apply the Snippets List Order setting again - #465

Closed
TallblokeUK wants to merge 2 commits into
core-betafrom
fix/list-order/core
Closed

fix: apply the Snippets List Order setting again#465
TallblokeUK wants to merge 2 commits into
core-betafrom
fix/list-order/core

Conversation

@TallblokeUK

@TallblokeUK TallblokeUK commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

The bug

Reported from support: Settings → Snippets List Order has no effect. Whichever of its five options you pick, the All Snippets table opens in the same order.

Reproduced on two clean installs — WP 7.0.4 / PHP 8.2.33 and WP 7.1 / PHP 8.3.33. Name (Z-A) should invert the list; nothing moved on either.

Cause

The setting is still defined and still rendered, but nothing reads it. Its only two references in 3.10.0:

Settings_Fields.php:91    'list_order' => 'priority-asc',   ← default value
Settings_Fields.php:191   'list_order' => [ … ],            ← the field in Settings

Until 3.10 the list table applied it directly:

// 3.9.2 — class-list-table.php:1311
$order = Settings\get_setting( 'general', 'list_order' );

Sorting moved to the column headings during the admin rewrite. The consumer went with the old table; the setting stayed in the UI, reading nothing.

Approach

The headings are the mechanism now, so this doesn't restore a parallel ordering system. It maps the setting onto the table's opening sort — which is what the setting describes itself as: "Default way to order snippets on the All Snippets admin menu."

  • list_order is localized alongside the other manage data
  • mapped to a column id and direction (priority/name/date, asc/desc)
  • passed to ListTable as a new optional initialSort

Clicking a heading overrides it for the rest of the visit, exactly as it overrides any other starting order. The initialSort prop is optional, so no other ListTable consumer changes behaviour.

On removing it instead: that was the alternative, and it's defensible given headings supersede it. I didn't, because it's a visible feature removal for anyone who has it configured, and the value is carried in saved settings either way — honouring it costs less than taking it away. Easy to flip if you'd rather retire the setting.

Verification

Against a reproduction of the reported environment (WP 7.0.4, PHP 8.2.33, 3.10.0, 190 snippets):

list_order before after
priority-asc Repro 001, 002, 003, 004 Repro 002, 003, 004, 005
name-desc Repro 001, 002, 003, 004 Repro 190, 189, 188, 187

An e2e test covers it and fails without the change. Full suite: 90 Playwright, 157 PHPUnit, 0 failures; lint:js and lint:styles clean.

Manage_Menu_Assets_Test pins the localized key list, so it gains listOrder.

Note

No changelog entry, consistent with #461, #462 and #463.

Fixes #474

"Snippets List Order" in Settings had no effect: whichever of its five
options was chosen, the table opened in the same order.

The setting is still defined and still rendered, but nothing reads it.
Its only two references in the codebase are its default value and its
field definition. Until 3.10 the list table applied it directly, in
`class-list-table.php`:

    $order = Settings\get_setting( 'general', 'list_order' );

Sorting moved to the column headings during the admin rewrite, and the
consumer went with the old table while the setting stayed in the UI.

The headings are the right mechanism now, so rather than restore a
parallel ordering system this maps the setting onto the table's opening
sort, which is what it describes itself as: "Default way to order
snippets on the All Snippets admin menu." `list_order` is localized,
mapped to a column and direction, and passed to `ListTable` as
`initialSort`. Clicking a heading overrides it for the rest of the
visit, exactly as it overrides any other starting order.

Removing the setting was the alternative. It would have been a visible
feature removal for anyone who has it configured, and the option is
carried in saved settings either way, so honouring it costs less than
taking it away.

Verified against a reproduction of the reported environment — WordPress
7.0.4, PHP 8.2.33, 3.10.0, 190 snippets. Before, every option produced
an identical list; after, "Name (Z-A)" inverts it. Covered by an e2e
test that fails without the change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
selectAllControl?: boolean

/** Column and direction to sort by before the reader touches a heading. */
initialSort?: { columnId: string, direction: ListTableSortDirection }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this is better passed as separate values instead of an object?

* setting still decides how the list opens; clicking a heading overrides it for
* the rest of the visit, as it does for any other starting order.
*/
const LIST_ORDER_SORTS: Record<string, { columnId: string, direction: ListTableSortDirection }> = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to encode a table – just partition on - and pass the first half as the column ID, the second as the direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-tests Trigger automated tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snippets List Order setting has no effect

3 participants