Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 fix: snackbar z-index #680

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion packages/yoga/src/Snackbar/web/Snackbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ import Button from '../../Button';
import Icon from '../../Icon';
import Text from '../../Text';

function getMaxZIndex() {
return Math.max(
...Array.from(document.querySelectorAll('body *'), el =>
parseFloat(window.getComputedStyle(el).zIndex),
).filter(zIndex => !Number.isNaN(zIndex)),
0,
);
}

const IconButtonWrapper = styled.div`
display: flex;
align-items: center;
Expand Down Expand Up @@ -69,7 +78,7 @@ const StyledSnackbar = styled.div`

background-color: ${snackbar.variant.color[variant]};

z-index: 100;
z-index: ${getMaxZIndex() + 1};
`}

${media.md`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ exports[`<Snackbar /> should match snapshot 1`] = `
border-radius: 8px;
box-shadow: 0 2px 4px -1px rgba(152,152,166,0.2),0 4px 5px 0px rgba(152,152,166,0.14),0 1px 10px 0px rgba(152,152,166,0.12);
background-color: #C1EEDB;
z-index: 100;
z-index: 1;
-webkit-animation: bcCCNc 0.2s ease-in-out;
animation: bcCCNc 0.2s ease-in-out;
}
Expand Down
Loading