diff --git a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-constituenta/editor-constituenta.tsx b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-constituenta/editor-constituenta.tsx index c120dfca..4b7f57f3 100644 --- a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-constituenta/editor-constituenta.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-constituenta/editor-constituenta.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import clsx from 'clsx'; import { useWindowSize } from '@/hooks/use-window-size'; @@ -20,7 +20,8 @@ import { ToolbarConstituenta } from './toolbar-constituenta'; const SIDELIST_LAYOUT_THRESHOLD = 1000; // px export function EditorConstituenta() { - const { schema, activeCst, isContentEditable, moveUp, moveDown, cloneCst, navigateCst } = useRSEdit(); + const { schema, activeCst, isContentEditable, selected, setSelected, moveUp, moveDown, cloneCst, navigateCst } = + useRSEdit(); const windowSize = useWindowSize(); const mainHeight = useMainHeight(); @@ -33,6 +34,12 @@ export function EditorConstituenta() { const disabled = !activeCst || !isContentEditable || isProcessing; const isNarrow = !!windowSize.width && windowSize.width <= SIDELIST_LAYOUT_THRESHOLD; + useEffect(() => { + if (activeCst && selected.length !== 1) { + setSelected([activeCst.id]); + } + }, [activeCst, selected, setSelected]); + function handleInput(event: React.KeyboardEvent) { if (disabled) { return;