Skip to content

Commit

Permalink
fix: make sure selected roi is rendered on top of other rois (#46)
Browse files Browse the repository at this point in the history
Prevents other rois to be selected when clicking on the selected roi
close #37
  • Loading branch information
josoriom authored Nov 6, 2023
1 parent c7068d0 commit 6963ba3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/components/api/RoiList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { useRois } from '../../hooks';
import { useRoiState, useRois } from '../../hooks';
import { assert } from '../../utilities/assert';

import { RoiBox } from './RoiBox';

export function RoiList() {
const rois = useRois();
const rois = useRois().slice();
const { selectedRoi } = useRoiState();
if (selectedRoi) {
const index = rois.findIndex((roi) => roi.id === selectedRoi);
assert(index !== -1, 'Selected ROI not found');
const roi = rois.splice(index, 1)[0];
rois.push(roi);
}
return (
<>
{rois.map((roi) => (
Expand Down
1 change: 0 additions & 1 deletion src/context/updaters/endAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export function endAction(draft: ReactRoiState) {
if (!selectedRoi) return;
const roi = rois.find((roi) => roi.id === selectedRoi);
const commitedRoi = committedRois.find((roi) => roi.id === selectedRoi);
assert(roi, 'Selected ROI not found');

if (!roi) return;

Expand Down

0 comments on commit 6963ba3

Please sign in to comment.