Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/compass-components/src/hooks/use-toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ const ToastAreaMountedContext = React.createContext(false);

export const ToastArea: React.FunctionComponent = ({ children }) => {
const stackedContext = useStackedComponent();
// We always want to show the toast over modal or other stacked components that may hide the toast and hence +1
const stackedElemStyles = useMemo(() => {
const zIndex = stackedContext?.zIndex ? stackedContext.zIndex + 1 : 1;
// We always want to show the toast under the modal
const toastPortalStyles = useMemo(() => {
const zIndex = stackedContext?.zIndex ? stackedContext.zIndex - 1 : 0;
Copy link
Preview

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting z-index to 0 when no stacked context exists may cause toasts to appear behind other page elements. Consider using a positive default value like 1 to ensure toasts remain visible above normal page content.

Suggested change
const zIndex = stackedContext?.zIndex ? stackedContext.zIndex - 1 : 0;
const zIndex = stackedContext?.zIndex ? stackedContext.zIndex - 1 : 1;

Copilot uses AI. Check for mistakes.

return css({ zIndex });
}, [stackedContext]);

Expand All @@ -207,7 +207,7 @@ export const ToastArea: React.FunctionComponent = ({ children }) => {

return (
<ToastAreaMountedContext.Provider value={true}>
<ToastProvider portalClassName={stackedElemStyles}>
<ToastProvider portalClassName={toastPortalStyles}>
<ToastStateHandler>{children}</ToastStateHandler>
</ToastProvider>
</ToastAreaMountedContext.Provider>
Expand Down