Skip to content

Commit

Permalink
fix 🐛: zindex position bug
Browse files Browse the repository at this point in the history
  • Loading branch information
BQXBQX committed Oct 29, 2024
1 parent a811902 commit ef98f85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packages/ui-react/lib/Toast/showToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const moreTimeClose = (div: HTMLDivElement) => {
if (toastContainer?.contains(div)) {
toastContainer?.removeChild(div);
toasts = toasts.filter((toast) => toast !== div);
checkToastContainer(); // Check if toasts are empty
}
}, 400);
}, 5000);
Expand All @@ -55,16 +56,18 @@ const moreThreeClose = () => {
if (toasts.length > 3) {
toasts.shift();
setTimeout(() => {
while (toastContainer && toastContainer?.childNodes.length > 3 && toastContainer.firstChild) {
while (toastContainer && toastContainer.childNodes.length > 3 && toastContainer.firstChild) {
toastContainer.removeChild(toastContainer.firstChild);
}
checkToastContainer(); // Check if toasts are empty
}, 300);
}
};

const closeToast = (div: HTMLDivElement) => {
setTimeout(() => {
div.remove();
checkToastContainer(); // Check if toasts are empty
}, 300);
toasts = toasts.filter((toast) => toast !== div);
addListener(div);
Expand Down Expand Up @@ -103,3 +106,10 @@ const addListener = (div: HTMLDivElement) => {
div.addEventListener('mouseenter', handleMouseEnter);
div.addEventListener('mouseleave', handleMouseLeave);
};

const checkToastContainer = () => {
if (toasts.length === 0 && toastContainer) {
document.body.removeChild(toastContainer);
toastContainer = null; // Reset toastContainer
}
};
2 changes: 1 addition & 1 deletion packages/ui-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ui-aurora/react",
"version": "0.0.29",
"version": "0.0.30",
"description": "A React UI library built for SASTOJ",
"author": "sast",
"license": "MIT",
Expand Down

1 comment on commit ef98f85

@vercel
Copy link

@vercel vercel bot commented on ef98f85 Oct 29, 2024

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

sast-ui – ./

sast-ui-sast.vercel.app
sast-ui-git-main-sast.vercel.app

Please sign in to comment.