fix(web): portal the natal board peek without effect setState
Quality gate lint failed on setHeaderSlot inside useLayoutEffect, so staging never published. Pass the header mount node from a callback ref instead. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -36,6 +36,7 @@ export type ConversationalBirthTimeRectificationProps = Readonly<{
|
||||
onStartConsultation?: () => void;
|
||||
pendingConsultationQuestion?: string | null;
|
||||
onRestart?: () => void;
|
||||
headerSlot: HTMLElement | null;
|
||||
}>;
|
||||
|
||||
export function ConversationalBirthTimeRectification(props: ConversationalBirthTimeRectificationProps) {
|
||||
|
||||
@@ -142,6 +142,7 @@ type RectificationAgenticChatProps = Readonly<{
|
||||
onStartConsultation?: () => void;
|
||||
pendingConsultationQuestion?: string | null;
|
||||
onRestart?: () => void;
|
||||
headerSlot: HTMLElement | null;
|
||||
}>;
|
||||
|
||||
type RenderMessage = ChatMessageView & {
|
||||
@@ -240,6 +241,7 @@ export function RectificationAgenticChat(props: RectificationAgenticChatProps) {
|
||||
onStartConsultation,
|
||||
pendingConsultationQuestion,
|
||||
onRestart,
|
||||
headerSlot,
|
||||
} = props;
|
||||
|
||||
const [messages, setMessages] = useState<RenderMessage[]>(() => messagesFromTurns(initialTurns));
|
||||
@@ -263,14 +265,9 @@ export function RectificationAgenticChat(props: RectificationAgenticChatProps) {
|
||||
const [compactBoard, setCompactBoard] = useState(false);
|
||||
const [boardOpen, setBoardOpen] = useState(false);
|
||||
const [boardDiff, setBoardDiff] = useState(() => diffRectificationBoard(null, null));
|
||||
const [headerSlot, setHeaderSlot] = useState<HTMLElement | null>(null);
|
||||
const boardId = useId();
|
||||
const boardTitleId = useId();
|
||||
|
||||
useLayoutEffect(() => {
|
||||
setHeaderSlot(document.querySelector("[data-rectification-header-slot]"));
|
||||
}, []);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const query = window.matchMedia(`(max-width: ${RECTIFICATION_BOARD_SPLIT_MIN_PX - 1}px)`);
|
||||
const update = () => {
|
||||
|
||||
Reference in New Issue
Block a user