Skip to content

Commit

Permalink
fix: Set current to null if no overlay remains on unmount (toss#40)
Browse files Browse the repository at this point in the history
* fix: Set current to null if no overlay remains on unmount

Co-authored-by: jgjgill <[email protected]>

* chore: changeset

---------

Co-authored-by: jgjgill <[email protected]>
  • Loading branch information
jungpaeng and jgjgill authored Jul 5, 2024
1 parent 45f9df8 commit c0aab02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/soft-jokes-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'overlay-kit': patch
---

Set current to null if no overlay remains on unmount
4 changes: 2 additions & 2 deletions packages/src/context/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function overlayReducer(state: OverlayData, action: OverlayReducerAction)
delete copiedOverlayData[action.overlayId];

return {
current: remainingOverlays.at(-1) || state.current,
current: remainingOverlays.at(-1) ?? null,
overlayOrderList: remainingOverlays,
overlayData: copiedOverlayData,
};
Expand All @@ -75,7 +75,7 @@ export function overlayReducer(state: OverlayData, action: OverlayReducerAction)
};
}
case 'REMOVE_ALL': {
return { current: state.current, overlayOrderList: [], overlayData: {} };
return { current: null, overlayOrderList: [], overlayData: {} };
}
}
}

0 comments on commit c0aab02

Please sign in to comment.