Skip to content

Commit

Permalink
#1140 - trying to fix the newestOnTop issue
Browse files Browse the repository at this point in the history
Not 100% sure if this is how it should be done, but when I ran things
with this change (both locally and with a build and deployment) it
seemed to work.
  • Loading branch information
cpfnickhoward authored and fkhadra committed Oct 13, 2024
1 parent 801a3ea commit 3dd6e4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/containerObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,6 @@ export function createContainerObserver(
toasts.get(id)!.toggle = fn;
},
isToastActive: (id: Id) => activeToasts.some(v => v === id),
getSnapshot: () => (props.newestOnTop ? snapshot.reverse() : snapshot)
getSnapshot: () => snapshot
};
}
4 changes: 4 additions & 0 deletions src/hooks/useToastContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export function useToastContainer(props: ToastContainerProps) {

const toRender = new Map<ToastPosition, Toast[]>();

if (props.newestOnTop) {
snapshot.reverse();
}

snapshot.forEach(toast => {
const { position } = toast.props;
toRender.has(position) || toRender.set(position, []);
Expand Down

0 comments on commit 3dd6e4d

Please sign in to comment.