feat(bookings): conditionally show heading/subtitle based on view (#25889)

* feat(bookings): conditionally show heading/subtitle based on view

- Add heading and subtitle props back to ShellMainAppDir in page.tsx
- Use headerClassName marker to identify the heading element
- Add useLayoutEffect in BookingCalendarContainer to hide heading when calendar view is mounted
- Restore heading visibility when switching back to list view

Co-Authored-By: [email protected] <[email protected]>

* refactor(bookings): extract shell heading visibility into reusable hook

- Create useBookingsShellHeadingVisibility hook with explicit visible parameter
- Move visibility logic from BookingCalendarContainer to BookingsContent
- Use data attribute to track if we hid the header (idempotent/Strict-Mode-safe)
- Explicit show/hide based on view state instead of relying on unmount

Co-Authored-By: [email protected] <[email protected]>

* refactor(bookings): simplify shell heading visibility hook

Remove HIDDEN_DATA_ATTR tracking since the header wrapper won't have
a hidden class from any other source

Co-Authored-By: [email protected] <[email protected]>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Eunjae LeeandDevin AI authored and GitHub committed 2025-12-17 12:46:12 +00:00
1 parent 970af8bd6a
commit e0a28af46e
3 files changed
+34 -2

No files matched your search

@@ -0,0 +1,25 @@
"use client";
import { useLayoutEffect } from "react";
const MARKER_CLASS = "bookings-shell-heading";
export function useBookingsShellHeadingVisibility({ visible }: { visible: boolean }) {
useLayoutEffect(() => {
const marker = document.querySelector(`.${MARKER_CLASS}`);
if (!marker) return;
const headerWrapper = marker.closest("header")?.parentElement;
if (!headerWrapper) return;
if (visible) {
headerWrapper.classList.remove("hidden");
} else {
headerWrapper.classList.add("hidden");
}
return () => {
headerWrapper.classList.remove("hidden");
};
}, [visible]);
}
@@ -10,6 +10,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import classNames from "@calcom/ui/classNames";
import { BookingListContainer } from "../components/BookingListContainer";
import { useBookingsShellHeadingVisibility } from "../hooks/useBookingsShellHeadingVisibility";
import { useBookingsView } from "../hooks/useBookingsView";
import type { validStatuses } from "../lib/validStatuses";
@@ -70,6 +71,8 @@ export default function Bookings(props: BookingsProps) {
function BookingsContent({ status, permissions, bookingsV3Enabled }: BookingsProps) {
const [view] = useBookingsView({ bookingsV3Enabled });
useBookingsShellHeadingVisibility({ visible: view === "list" });
return (
<div className={classNames(view === "calendar" && "-mb-8")}>
{view === "list" && (