fix(canvas): add null checks for canvas manager and bbox selectors

- Fixed CanvasPasteModal null checks for canvasManager and getBbox()
- Fixed CanvasHUDItemBbox null check for bbox selector
- Fixed RegionalGuidanceEntityList null check for canvas selector

These fixes resolve TypeScript null pointer errors in canvas components.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
psychedelicious
2025-09-02 19:23:14 +10:00
parent 439969b698
commit f3f6049604
4 changed files with 16 additions and 4 deletions

View File

@@ -37,7 +37,14 @@ export const CanvasPasteModal = memo(() => {
const getPosition = useCallback(
(destination: 'canvas' | 'bbox') => {
const { x, y } = canvasManager.stateApi.getBbox().rect;
if (!canvasManager) {
return { x: 0, y: 0 };
}
const bbox = canvasManager.stateApi.getBbox();
if (!bbox) {
return { x: 0, y: 0 };
}
const { x, y } = bbox.rect;
if (destination === 'bbox') {
return { x, y };
}
@@ -50,7 +57,7 @@ export const CanvasPasteModal = memo(() => {
return { x, y };
}
},
[canvasManager.compositor, canvasManager.stateApi]
[canvasManager?.compositor, canvasManager?.stateApi]
);
const handlePaste = useCallback(

View File

@@ -5,7 +5,7 @@ import { selectBbox } from 'features/controlLayers/store/selectors';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
const selectBboxRect = createSelector(selectBbox, (bbox) => bbox.rect);
const selectBboxRect = createSelector(selectBbox, (bbox) => bbox?.rect || { width: 0, height: 0 });
export const CanvasHUDItemBbox = memo(() => {
const { t } = useTranslation();

View File

@@ -8,6 +8,7 @@ import { getEntityIdentifier } from 'features/controlLayers/store/types';
import { memo } from 'react';
const selectEntityIdentifiers = createMemoizedSelector(selectCanvasSlice, (canvas) => {
if (!canvas) return [];
return canvas.regionalGuidance.entities.map(getEntityIdentifier).toReversed();
});
const selectIsSelected = createSelector(selectSelectedEntityIdentifier, (selectedEntityIdentifier) => {

View File

@@ -25,7 +25,11 @@ Started: 2025-09-02
- ❌ Settings accordion property access errors
### Fixes Applied
None yet.
-**Import/Export Errors Fixed (2 commits)**
- Added missing `rasterLayerConverted*` action exports to canvasInstanceSlice
- Added missing bbox, entity, and drawing action exports
- Fixed `canvasClearHistory` import in imageActions to come from canvasesSlice
- Fixed `rgAdded` export name (was incorrectly exported as `regionalGuidanceAdded`)
## Next Steps
1. Fix missing rasterLayer conversion actions in canvasInstanceSlice