This commit is contained in:
iqudoo
2026-06-13 01:35:20 +08:00
parent 4167fb2683
commit f2689520bd
3 changed files with 68 additions and 10 deletions

View File

@@ -73,6 +73,17 @@ const MARQUEE_MIN_PX = 4;
const DRAG_START_THRESHOLD_PX = 4;
const MODERATE_ZOOM_MAX = 2.0;
function blurActiveField() {
const active = document.activeElement;
if (
active instanceof HTMLInputElement ||
active instanceof HTMLTextAreaElement ||
active instanceof HTMLSelectElement
) {
active.blur();
}
}
function rectFullyContains(
outer: { left: number; top: number; right: number; bottom: number },
inner: { left: number; top: number; right: number; bottom: number }
@@ -445,7 +456,7 @@ export const LabelDesigner: React.FC<LabelDesignerProps> = ({
if (isTiny) {
if (!state.additive) {
onSelectElements([]);
requestAnimationFrame(() => onSelectElements([]));
}
return;
}
@@ -618,6 +629,8 @@ export const LabelDesigner: React.FC<LabelDesignerProps> = ({
const canvas = canvasRef.current;
if (!canvas) return;
blurActiveField();
const rect = canvas.getBoundingClientRect();
const startX = e.clientX - rect.left;
const startY = e.clientY - rect.top;
@@ -814,7 +827,7 @@ export const LabelDesigner: React.FC<LabelDesignerProps> = ({
return;
}
if (e.target === e.currentTarget) {
onSelectElements([]);
requestAnimationFrame(() => onSelectElements([]));
}
}}
>