Skip to content

Commit

Permalink
Merge pull request #388 from NDLA-H5P/feature/show_arrows_again_in_ed…
Browse files Browse the repository at this point in the history
…itor

redraw arrows when editing existing document
  • Loading branch information
kentis authored Mar 8, 2022
2 parents 1dfd205 + e2f263b commit 6f70b42
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .storybook/helpers/h5p.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export const params: Params = {
label: "",
startPosition: { x: 0, y: 0 },
endPosition: { x: 0, y: 0 },
startGridPosition: { x: 0, y: 0 },
endGridPosition: { x: 0, y: 0 },
},
],
colorTheme: ColorTheme.Blue,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const Grid: FC<GridProps> = ({
const [arrowItems, setArrowItems] = useState(initialArrowItems ?? []);
const [classicArrowItems, setClassicArrowItems] = useState<
Array<ClassicArrowItemType>
>([]);
>((initialArrowItems as ClassicArrowItemType[]) ?? []);
const [occupiedCells, setOccupiedCells] = useState<Array<OccupiedCell>>([]);
const [boxStartIndex, setBoxStartIndex] = useState<number | null>(null);
const [isDragging, setIsDragging] = useState(false);
Expand Down Expand Up @@ -136,6 +136,7 @@ export const Grid: FC<GridProps> = ({
useEffectOnce(() => {
// eslint-disable-next-line no-param-reassign
updateGrid.current = updateLocalGrid;
updateGridDimensions({ numberOfColumns, numberOfRows });
});

const elementRef = useRef<HTMLDivElement>(null);
Expand Down
3 changes: 3 additions & 0 deletions src/types/ArrowItemType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ export type ArrowItemType = CommonItemType & {

startPosition: Position;
endPosition: Position;

startGridPosition: Position;
endGridPosition: Position;
};
2 changes: 2 additions & 0 deletions src/utils/grid.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ export const createArrowItem = (
endElementId: endId,
startPosition: { x: 0, y: 0 },
endPosition: { x: 0, y: 0 },
startGridPosition: { x: 0, y: 0 },
endGridPosition: { x: 0, y: 0 },
};

return item;
Expand Down

0 comments on commit 6f70b42

Please sign in to comment.