Gate search behind CompanySettings.searchEnabled; fix two reported bugs
Search icon now gated behind the new backend toggle, same pattern as wishlistEnabled — off by default. Fixed: blog category filter bar was invisible — it was wrapped in <Reveal>, which sits right at/just past the hero's bottom edge, the exact "already near the initial viewport" position Reveal.tsx's own comment documents as a whileInView(margin:"-80px") trap (an element already visible without scrolling can permanently never register as "entered view", since `once: true` never gets a second chance). Now a plain div, no scroll-reveal animation needed for a filter bar anyway. Fixed: wishlist count showing one behind on the Navbar badge — useWishlist.ts's toggle() broadcast the "refetch me" event immediately after the optimistic local update, before the POST request was even sent. Another instance's resulting refetch could race the actual server-side write, get the pre-toggle list, and then never get told to refetch again. Broadcast now only fires after the request settles. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+8
-3
@@ -4,7 +4,7 @@ import "./globals.css";
|
||||
import { Navbar } from "./components/Navbar";
|
||||
import { CartFlyProvider } from "./components/CartFly";
|
||||
import { CartSync } from "./components/CartSync";
|
||||
import { getProducts, getSeoSettings, getCompanySettings, getWishlistEnabled } from "./lib/payload";
|
||||
import { getProducts, getSeoSettings, getCompanySettings, getWishlistEnabled, getSearchEnabled } from "./lib/payload";
|
||||
import { buildOrganizationSchema } from "./lib/structuredData";
|
||||
|
||||
const inter = Inter({
|
||||
@@ -67,7 +67,12 @@ export default async function RootLayout({
|
||||
// just to know whether Navbar's "Shop" link should behave as an anchor
|
||||
// to the homepage spotlight instead of a real /shop navigation (see
|
||||
// Navbar.tsx/ProductSpotlight.tsx).
|
||||
const [products, seller, wishlistEnabled] = await Promise.all([getProducts(), getCompanySettings(), getWishlistEnabled()]);
|
||||
const [products, seller, wishlistEnabled, searchEnabled] = await Promise.all([
|
||||
getProducts(),
|
||||
getCompanySettings(),
|
||||
getWishlistEnabled(),
|
||||
getSearchEnabled(),
|
||||
]);
|
||||
const singleActiveProduct = products.filter((p) => p.active).length === 1;
|
||||
// Organization JSON-LD on every page — one canonical node (@id) that
|
||||
// Product/Article schemas elsewhere link back to via `{ "@id": ... }`
|
||||
@@ -87,7 +92,7 @@ export default async function RootLayout({
|
||||
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(organizationSchema) }} />
|
||||
<CartFlyProvider>
|
||||
<CartSync />
|
||||
<Navbar singleActiveProduct={singleActiveProduct} wishlistEnabled={wishlistEnabled} />
|
||||
<Navbar singleActiveProduct={singleActiveProduct} wishlistEnabled={wishlistEnabled} searchEnabled={searchEnabled} />
|
||||
{children}
|
||||
</CartFlyProvider>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user