From 65440e29f061dad92afa2a74b237bd2cb8db835b Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Thu, 19 Jun 2025 18:12:58 +0300 Subject: [PATCH] B: Adjust selection for Constituenta editor --- .../editor-constituenta/editor-constituenta.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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;