Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/components/codeBlock/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import {RefObject, useEffect, useRef, useState} from 'react';
import {RefObject, useEffect, useLayoutEffect, useRef, useState} from 'react';
import {Clipboard} from 'react-feather';

import {usePlausibleEvent} from 'sentry-docs/hooks/usePlausibleEvent';
Expand Down Expand Up @@ -61,9 +61,14 @@ export function CodeBlock({filename, language, children}: CodeBlockProps) {
const [isMounted, setIsMounted] = useState(false);
const {emit} = usePlausibleEvent();

// Use useLayoutEffect to set isMounted synchronously before browser paints
// This ensures keyword interpolation happens before the user sees anything
useLayoutEffect(() => {
setIsMounted(true);
}, []);

useEffect(() => {
setShowCopyButton(true);
setIsMounted(true);
// prevent .no-copy elements from being copied during selection Right click copy or / Cmd+C
const noCopyElements = codeRef.current?.querySelectorAll<HTMLSpanElement>('.no-copy');
const handleSelectionChange = () => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/codeKeywords/keyword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import {MotionProps} from 'framer-motion';
import {KeywordSpan} from './styles';

export function Keyword({
initial = {opacity: 0, y: -10, position: 'absolute'},
initial = false, // Disable initial animation on mount to prevent flash
animate = {
position: 'relative',
opacity: 1,
y: 0,
transition: {delay: 0.1},
},
exit = {opacity: 0, y: 20},
transition = {
Expand Down
Loading