Newsletter: gate placement "Preview and edit" link on saved-enabled state#49532
Newsletter: gate placement "Preview and edit" link on saved-enabled state#49532CGastrell wants to merge 2 commits into
Conversation
…pinner flash The modernized dashboard mounts NewsletterSettingsBody inside a Tabs.Panel that unmounts on tab switch and remounts on return. With isLoading initialized to true and no cache, every revisit re-flashed the full-page spinner while re-fetching. Seed the loading/data state from a module-level cache so repeat mounts paint immediately; the genuine first load still shows the spinner, and the mount effect keeps refreshing in the background.
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 4 files.
Full summary · PHP report · JS report If appropriate, add one of these labels to override the failing coverage check:
Covered by non-unit tests
|
…tate The subscription placement "Preview and edit" link was gated only on site capability, so it appeared for placements that were disabled or toggled-but- unsaved — clicking it opened an empty Site Editor preview. Show the link only when the placement is enabled in its saved state (enabled in data and not in the pending changeset).
fc3134f to
85ff8e9
Compare
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Follow-up note: a pre-existing "phantom unsaved edit" issue (not fixed here)Flagging for later — out of scope for this PR. The Settings body caches the optimistic The |
10770ad to
1eace63
Compare
Part of #49485 - NL08
Proposed changes
savedData) rather than "untouched since save", which keeps the link reversible: toggle a saved-on placement off and back on and the link returns immediately, without a round-trip to the server. A freshly enabled-but-unsaved placement still stays linkless until the save lands. The existing site-capability gating (block theme / theme stylesheet / subscription-site-edit support) is preserved.datais updated optimistically while the key is tracked in a pending changeset that's cleared on save. The page previously kept no record of the last-persisted values, so the first version of this fix had to use "key is in the pending changeset" as a proxy for "unsaved". That proxy is touch-based, not value-based: toggling a saved-on placement off then on left the key marked dirty, so the link stayed hidden until an actual save — even though the saved state never changed. This version introducessavedData, a persisted baseline set on load and advanced on every successful save, and gates the link ondata[ key ] && savedData[ key ]. The baseline is module-cached (parallel to Newsletter: Stop the modernized Settings spinner from flashing on every visit #49530's optimistic cache) so it survives the tab unmount/remount without the link blinking off on return.This only touches the placement-card grid. The Navigation subgroup's "Preview and edit" links are intentionally out of scope here (they share the same "empty preview when unsaved" critique — a reasonable follow-up).
Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Prerequisite: a site with the modernized Newsletter dashboard enabled (modernization filter on) and a block theme so the Site Editor links are eligible.
Automated coverage:
tests/subscriptions-section.test.tsxasserts the link shows for enabled-and-saved placements (including the reverted-to-saved case) and is hidden for disabled, enabled-but-unsaved, and capability-ineligible cases (jp test js packages/newsletter).