Skip to content

Commit 732095e

Browse files
committed
refactor(properties): require canvasRef on PropertiesPanel
Optional+default-{} let a missing ref silently no-op the align buttons. Required prop forces AppShell to wire it; the inner `.current?` guard is enough — it only covers the pre-mount window.
1 parent 6084cc0 commit 732095e

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎src/components/Properties/PropertiesPanel.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ import type { LabelConfig } from "../../types/ObjectType";
2424

2525
interface PropertiesPanelProps {
2626
/** Imperative handle on the canvas — used for actions that need live render
27-
* bboxes (alignment, future zoom-to-selection, etc.). Optional: when no
28-
* object is selected, the panel falls back to label config and the ref is
29-
* unused. */
30-
canvasRef?: RefObject<LabelCanvasHandle | null>;
27+
* bboxes (alignment, future zoom-to-selection, etc.). Required so the
28+
* type system forces the caller to wire it up; the inner null-check on
29+
* `.current` only covers the brief window before LabelCanvas mounts. */
30+
canvasRef: RefObject<LabelCanvasHandle | null>;
3131
}
3232

33-
export function PropertiesPanel({ canvasRef }: PropertiesPanelProps = {}) {
33+
export function PropertiesPanel({ canvasRef }: PropertiesPanelProps) {
3434
const t = useT();
3535
const {
3636
selectedIds,
@@ -44,7 +44,7 @@ export function PropertiesPanel({ canvasRef }: PropertiesPanelProps = {}) {
4444
const unit = canvasSettings.unit;
4545
const obj = objects.find((o) => o.id === selectedIds[0]);
4646
const handleAlign = (axis: AlignAxis) =>
47-
canvasRef?.current?.alignSelectionToLabel(axis);
47+
canvasRef.current?.alignSelectionToLabel(axis);
4848

4949
if (selectedIds.length > 1) {
5050
return (

0 commit comments

Comments
 (0)