Fix P1 issues
This commit is contained in:
@@ -6,6 +6,7 @@ export function ConnectionLayer() {
|
|||||||
const { racks, cablingFromPortId, setActiveConfigConnectionId } = useRackStore();
|
const { racks, cablingFromPortId, setActiveConfigConnectionId } = useRackStore();
|
||||||
const [coords, setCoords] = useState<Record<string, { x: number; y: number }>>({});
|
const [coords, setCoords] = useState<Record<string, { x: number; y: number }>>({});
|
||||||
const [mousePos, setMousePos] = useState({ x: 0, y: 0 });
|
const [mousePos, setMousePos] = useState({ x: 0, y: 0 });
|
||||||
|
const [isShiftPressed, setIsShiftPressed] = useState(false);
|
||||||
|
|
||||||
// Update port coordinates
|
// Update port coordinates
|
||||||
const updateCoords = useCallback(() => {
|
const updateCoords = useCallback(() => {
|
||||||
@@ -78,6 +79,26 @@ export function ConnectionLayer() {
|
|||||||
return () => window.removeEventListener('mousemove', onMouseMove);
|
return () => window.removeEventListener('mousemove', onMouseMove);
|
||||||
}, [cablingFromPortId]);
|
}, [cablingFromPortId]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const syncShiftState = (event: KeyboardEvent) => {
|
||||||
|
setIsShiftPressed(event.shiftKey);
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearShiftState = () => {
|
||||||
|
setIsShiftPressed(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('keydown', syncShiftState);
|
||||||
|
window.addEventListener('keyup', syncShiftState);
|
||||||
|
window.addEventListener('blur', clearShiftState);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('keydown', syncShiftState);
|
||||||
|
window.removeEventListener('keyup', syncShiftState);
|
||||||
|
window.removeEventListener('blur', clearShiftState);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const connections = useMemo(() => {
|
const connections = useMemo(() => {
|
||||||
const conns: { id: string; from: string; to: string; color?: string; edgeType?: string }[] = [];
|
const conns: { id: string; from: string; to: string; color?: string; edgeType?: string }[] = [];
|
||||||
racks.forEach((rack) => {
|
racks.forEach((rack) => {
|
||||||
@@ -149,7 +170,7 @@ export function ConnectionLayer() {
|
|||||||
stroke="transparent"
|
stroke="transparent"
|
||||||
strokeWidth="10"
|
strokeWidth="10"
|
||||||
fill="none"
|
fill="none"
|
||||||
className="pointer-events-auto cursor-pointer"
|
className={isShiftPressed ? 'pointer-events-auto cursor-pointer' : 'pointer-events-none'}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|||||||
Reference in New Issue
Block a user