Skip to content

Add opt-in default for "Always open List View" in the Block Editor (#32) - #57

Open
roshniahuja wants to merge 3 commits into
WordPress:mainfrom
roshniahuja:feature/32-list-view-default
Open

Add opt-in default for "Always open List View" in the Block Editor (#32)#57
roshniahuja wants to merge 3 commits into
WordPress:mainfrom
roshniahuja:feature/32-list-view-default

Conversation

@roshniahuja

Copy link
Copy Markdown

Summary

Closes #32. Adds an opt-in, off-by-default option that turns on "Always open
List View" for the current user across every WordPress site's Block Editor
(post editor + Site Editor) — a one-time toggle instead of the per-site
manual step the issue describes.

How it works

  • WordPress persists this preference server-side under a single shared
    "core" preferences scope (getPreference("core", "showListViewByDefault")
    — same call in both edit-post.js and edit-site.js), not purely
    localStorage as the issue's acceptance criteria suggested. localStorage
    is still involved as a local write-through cache with timestamp-based
    conflict resolution, but the source of truth is server-side user meta,
    and both are read/written together through one preferences store.
  • lib/editor-preferences.js reads WordPress's own already-inlined
    preferences snapshot from the DOM (the same data wp.data hydrates from)
    to check, with no REST call, whether the preference is already on.
  • If it isn't, content.js asks background.js to dispatch
    wp.data.dispatch('core/preferences').set('core', 'showListViewByDefault', true)
    in the page's MAIN world — the same store action a user's own click on
    that Editor Preferences toggle triggers. WordPress's own existing
    debounced local-cache + REST persistence handles the actual save, so the
    extension never touches the REST API or the stored JSON directly — no
    risk of clobbering other saved preferences (dark mode, panel state, etc).

Data & privacy / permissions

  • No new manifest.json permissions — storage and scripting were
    already granted; the write happens through the page's own
    already-authenticated wp.data, not a new endpoint the extension calls.
  • Off by default. Only ever turns the preference on, never off.
  • New global option lives alongside the existing admin-bar/site-info
    defaults in wp_preferences_v1._global — no new storage keys.

Open question for maintainers

The issue's phrasing implies "just make it always on." I made it an
explicit opt-in toggle instead, matching the Site Info panel / admin-bar
precedent in this repo, since it writes to the signed-in user's own
account preferences. Happy to flip it to on-by-default if you'd rather
match the issue literally.

Test plan

  • cd test && npm test — new smoke coverage for
    lib/editor-preferences.js (DOM snapshot parsing, the "needs it" gate,
    new-account edge case, missing-preference-key edge case)
  • npm run build — clean
  • Manually verified end-to-end against a real logged-in WordPress
    editor session: baseline showListViewByDefault: false → enable the new
    option → reload the editor → true, confirmed persisted server-side via
    a fresh page load re-reading WordPress's own hydrated snapshot (not
    leftover client state) → reload again, stable, no repeat writes, no
    console errors

Comment thread lib/editor-preferences.js
Comment thread content.js
Comment thread background.js
Closes WordPress#32. WordPress persists this preference server-side under a
shared "core" preferences scope (same for the post editor and Site
Editor), so a new options-page toggle dispatches through the editor's
own preferences store to turn it on for the signed-in user across
every WordPress site — the same store update a manual click on that
Editor Preferences toggle performs. Off by default; only ever turns
the preference on, never off, and never touches the REST API or the
stored JSON directly.
…, sync Safari

- content.js/background.js: add a per-origin "already applied" marker so
  the List View default is only ever nudged on once per site, never
  re-forced after a user turns it back off themselves. background.js now
  captures the MAIN-world dispatch's actual result and only records the
  marker on a confirmed success.
- Confirmed body.block-editor-page is present on site-editor.php at
  document_idle (server-rendered, already in the initial HTML) — no
  selector change needed.
- scripts/sync-safari.sh: add the missing lib/editor-preferences.js copy
  and re-sync the Safari Resources mirror, which was missing the file
  entirely and would have thrown in the Safari service worker.
@roshniahuja
roshniahuja force-pushed the feature/32-list-view-default branch from aac1cde to 6946a29 Compare July 10, 2026 17:26
@roshniahuja
roshniahuja requested a review from itzmekhokan July 10, 2026 17:30
scripts/package-chrome.sh copies lib/* file-by-file and was missing
lib/editor-preferences.js — the Chrome counterpart of the sync-safari.sh
fix. Without it, npm run package:chrome fails the verify-package
integrity gate (referenced file missing), so no Chrome Web Store zip can
be produced. Verified: the packaged zip now contains the file and the
gate passes (23 files).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please let the browser extension default "Always open List View" in the Block Editor to on for all WordPress sites.

2 participants