Skip to content

fix(blog): stop gating "See preview" on unrelated content fields - #7152

Merged
yuriassuncx merged 1 commit into
mainfrom
fix/post-preview-not-gated-on-content-fields
Sep 11, 2026
Merged

yuriassuncx merged 1 commit into
mainfrom
fix/post-preview-not-gated-on-content-fields

Conversation

@yuriassuncx

@yuriassuncx yuriassuncx commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem

After #7150 (previewUrl route-resolution fix), "Ver visualização" still
shows disabled for some posts — e.g. Bagaggio's "Mochila Escolar..." draft,
which shows a red "1 problema" badge.

Root cause

#7150 fixed the right thing (previewUrl couldn't be built at all before),
but the button's disabled condition was never just about the URL:

disabled={!previewUrl || hasErrors}

hasErrors comes from missingPostFields() — Title, Slug, Category,
Excerpt, Cover image. Slug/Category are already covered: when either is
missing, buildBlogPostPreviewUrl → applyBlogPageSlug already returns
null, so previewUrl itself is falsy. But Title/Excerpt/Cover image have
zero bearing on whether the URL resolves — a draft missing its excerpt still
renders fine at its route. Gating preview on them conflates "is this
publish-ready" (correct place: the Published toggle, via
blocksPostStatus) with "can we open a preview link" (only needs
slug+category, i.e. previewUrl).

So once #7150 made previewUrl resolve correctly, the button still
stayed disabled for any post missing excerpt/cover image/title — same
symptom, different, independent gate.

Fix

disabled={!previewUrl}. The "N problema(s)" badge next to Saved is
untouched (still hasErrors-gated) — it keeps nudging toward
publish-readiness. This only stops it from also blocking the unrelated
preview button.

Test plan

  • tsc --noEmit (apps/web) clean
  • bun test blog-preview-url.test.ts — 34 pass (unchanged, this PR
    doesn't touch URL-building, only the button's gate)
  • Live: open a post missing excerpt/cover image (like the Bagaggio one
    in the report) and confirm "Ver visualização" is now clickable

Related

Follow-up to #7150 (Daniel Furtado) — same investigation thread as #7151
and spire-agent#12.

Co-Authored-By: Claude Sonnet 5 [email protected]


Summary by cubic

Fixes the blog post preview button so it's no longer disabled by content fields that don't affect the preview URL. Previously, drafts missing Title, Excerpt, or Cover image kept the button disabled even though only Slug and Category determine whether the URL resolves.

Bug Fixes

  • The disabled condition now only checks previewUrl; the "N problema(s)" badge still uses hasErrors and is unchanged.

Written for commit de0e103. Summary will update on new commits.

Review in cubic

#7150 fixed previewUrl resolution (Page-block fallback when the blog
app has no pageSlug/categorySlug) but the button stayed disabled for
posts still missing Title/Excerpt/Cover image — fields that have
nothing to do with whether the URL can be opened.

`disabled={!previewUrl || hasErrors}` conflated two different
questions: "can we build a working preview link" (slug + category —
already enforced inside buildBlogPostPreviewUrl/applyBlogPageSlug,
which return null when either is missing) and "is this post
publish-ready" (all 5 fields via missingPostFields, used to gate the
Published toggle). Preview only needs the former: a draft with no
excerpt/cover image still renders at its URL.

`disabled={!previewUrl}` alone already captures the real precondition.
The "N problema(s)" badge (still gated on hasErrors, unchanged) keeps
warning about missing publish fields — this only stops it from also
blocking the unrelated preview button.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@yuriassuncx
yuriassuncx merged commit 20028a1 into main Sep 11, 2026
34 checks passed
@yuriassuncx
yuriassuncx deleted the fix/post-preview-not-gated-on-content-fields branch September 11, 2026 00:07
decocms Bot pushed a commit that referenced this pull request Sep 11, 2026
PR: #7152 fix(blog): stop gating "See preview" on unrelated content fields
Bump type: patch

- decocms (apps/api/package.json): 4.353.1 -> 4.353.2
- @decocms/native (apps/native/package.json): 4.353.1 -> 4.353.2

Deploy-Scope: web
yuriassuncx added a commit that referenced this pull request Sep 11, 2026
…earch schemas (#7154)

#7151 added contentCollection/contentItem read + selection logic in
ContentBrowser (Blog Manager's "Editar no Studio" deep-link), but
neither the unified-chat route nor the agents route validateSearch
schema declared them. TanStack Router strips any search param a
route's validateSearch doesn't declare before the component ever sees
it via useSearch — so the redirect landed on an empty content editor
instead of the selected post, reproducing exactly what #7151 was
meant to fix.

Factor the content-editor search params (storefront "." deep-link +
Blog Manager deep-link) into one `content-search-params.ts` module
spread into both route schemas, so a future param ContentBrowser reads
can't silently be dropped by one route and not the other again.

The reported "Ver visualização" preview button issue was already
fixed on main by #7150 (route derivation) + #7152 (stop gating on
unrelated fields) earlier today — not reproducible against current
main, just not yet deployed to studio.decocms.com.

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
aka-sacci-ccr pushed a commit that referenced this pull request Sep 11, 2026
One conflict, in the post editor, and it was the interesting kind: both
sides had rewritten the same header.

The restructure moved the header block below a floating expand/close
cluster; upstream changed what's inside it. Kept the restructure's layout
and applied upstream's two behaviour changes into it, because taking
either side whole would have silently dropped a fix:

- #7152 ungated "See preview" from `hasErrors`. The restructure's copy
  still had `disabled={!previewUrl || hasErrors}`, which is the bug that
  PR fixes, so the gate is gone and the title no longer branches on it.
- #7147 gave `useAutosave` an `isSaving` option so overlapping autosaves
  stop dropping the penultimate edit. Threaded through, keeping
  `buildPostBlock` and the three-value destructure the restructure needs
  for `syncPost` on a block rename.

#7150's preview-route fix needed nothing here: the call site is identical
on both sides and the change lives in `buildBlogPostPreviewUrl`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.

1 participant