diff --git a/apps/web/src/components/ui/report/elements/CaptionNode.tsx b/apps/web/src/components/ui/report/elements/CaptionNode.tsx index 71ada7c5f..f318fc1c5 100644 --- a/apps/web/src/components/ui/report/elements/CaptionNode.tsx +++ b/apps/web/src/components/ui/report/elements/CaptionNode.tsx @@ -7,6 +7,7 @@ import { import type { VariantProps } from 'class-variance-authority'; import { cva } from 'class-variance-authority'; import type { TElement } from 'platejs'; +import { usePluginOption } from 'platejs/react'; import type * as React from 'react'; import { Button } from '@/components/ui/buttons'; import { cn } from '@/lib/utils'; @@ -49,11 +50,12 @@ export function CaptionTextarea(props: React.ComponentProps) => { const captionButtonState = useCaptionButtonState(); - - const hasCaption = (captionButtonState.element?.caption as TElement[])?.length > 0; + const visibleId = usePluginOption(CaptionPlugin, 'visibleId'); + const element = captionButtonState.element; + const isOpen = visibleId === element.id; + const hasCaption = (captionButtonState.element?.caption as TElement[]) !== undefined || isOpen; const text = hasCaption ? NodeTypeLabels.removeCaption.label : NodeTypeLabels.addCaption.label; const editor = captionButtonState.editor; - const element = captionButtonState.element; const addCaption = () => { const path = editor.api.findPath(element); diff --git a/apps/web/src/components/ui/report/elements/MetricElement/MetricToolbar.tsx b/apps/web/src/components/ui/report/elements/MetricElement/MetricToolbar.tsx index 93ba10cb1..b2845e215 100644 --- a/apps/web/src/components/ui/report/elements/MetricElement/MetricToolbar.tsx +++ b/apps/web/src/components/ui/report/elements/MetricElement/MetricToolbar.tsx @@ -72,10 +72,6 @@ export function MetricToolbar({ onOpenAutoFocus={(e) => e.preventDefault()} >
- {/* */} -