B: Adjust selection for Constituenta editor
Some checks failed
Frontend CI / build (22.x) (push) Has been cancelled
Frontend CI / notify-failure (push) Has been cancelled

This commit is contained in:
Ivan 2025-06-19 18:12:58 +03:00
parent 22d8e0fadd
commit 65440e29f0

View File

@ -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<HTMLDivElement>) {
if (disabled) {
return;