Skip to content

Commit

Permalink
fix(Modal): fix flaky overlay opacity color issue happening in Chrome…
Browse files Browse the repository at this point in the history
… browser

Here's a [reprod](https://codesandbox.io/s/eufemia-drawer-background-color-bug-ui417b?file=/src/App.tsx): (Shows a black overlay when opened)

Because it happen not on all Chrome browsers (all on latest) its hard to make a test that verifies the issue.
  • Loading branch information
tujoworker committed Jun 10, 2022
1 parent 20d2ea2 commit 86d875d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1980,11 +1980,11 @@ button.dnb-button::-moz-focus-inner {
from {
opacity: 0; }
to {
opacity: var(--modal-overlay-opacity); } }
opacity: 1; } }
@keyframes hide-modal-overlay {
from {
opacity: var(--modal-overlay-opacity); }
opacity: 1; }
to {
opacity: 0; } }
Expand Down Expand Up @@ -2346,8 +2346,7 @@ button.dnb-button::-moz-focus-inner {
:root {
--modal-z-index: 3000;
--modal-animation-duration: 300ms;
--modal-overlay-bg: black;
--modal-overlay-opacity: 0.32; }
--modal-overlay-bg: rgba(0, 0, 0, 0.32); }
html[data-dnb-modal-active] {
user-select: none;
Expand Down Expand Up @@ -2399,11 +2398,11 @@ html[data-dnb-modal-active] {
height: 100%;
background-color: var(--modal-overlay-bg); }
.dnb-modal-root__inner .dnb-modal__overlay {
animation: hide-modal-overlay var(--modal-animation-duration) ease-in-out forwards; }
animation: hide-modal-overlay var(--modal-animation-duration) ease-out forwards; }
.dnb-modal-root__inner:last-of-type .dnb-modal__overlay {
animation: show-modal-overlay var(--modal-animation-duration) ease-out forwards 0ms; }
animation: show-modal-overlay var(--modal-animation-duration) ease-out forwards; }
.dnb-modal-root__inner:last-of-type .dnb-modal__overlay--hide {
animation: hide-modal-overlay var(--modal-animation-duration) ease-in-out forwards; }
animation: hide-modal-overlay var(--modal-animation-duration) ease-out forwards; }
html[data-visual-test] .dnb-modal__overlay, .dnb-modal__overlay--no-animation {
animation-delay: 0ms !important;
animation-duration: 0ms !important; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1916,11 +1916,11 @@ button.dnb-button::-moz-focus-inner {
from {
opacity: 0; }
to {
opacity: var(--modal-overlay-opacity); } }
opacity: 1; } }
@keyframes hide-modal-overlay {
from {
opacity: var(--modal-overlay-opacity); }
opacity: 1; }
to {
opacity: 0; } }
Expand Down Expand Up @@ -2282,8 +2282,7 @@ button.dnb-button::-moz-focus-inner {
:root {
--modal-z-index: 3000;
--modal-animation-duration: 300ms;
--modal-overlay-bg: black;
--modal-overlay-opacity: 0.32; }
--modal-overlay-bg: rgba(0, 0, 0, 0.32); }
html[data-dnb-modal-active] {
user-select: none;
Expand Down Expand Up @@ -2335,11 +2334,11 @@ html[data-dnb-modal-active] {
height: 100%;
background-color: var(--modal-overlay-bg); }
.dnb-modal-root__inner .dnb-modal__overlay {
animation: hide-modal-overlay var(--modal-animation-duration) ease-in-out forwards; }
animation: hide-modal-overlay var(--modal-animation-duration) ease-out forwards; }
.dnb-modal-root__inner:last-of-type .dnb-modal__overlay {
animation: show-modal-overlay var(--modal-animation-duration) ease-out forwards 0ms; }
animation: show-modal-overlay var(--modal-animation-duration) ease-out forwards; }
.dnb-modal-root__inner:last-of-type .dnb-modal__overlay--hide {
animation: hide-modal-overlay var(--modal-animation-duration) ease-in-out forwards; }
animation: hide-modal-overlay var(--modal-animation-duration) ease-out forwards; }
html[data-visual-test] .dnb-modal__overlay, .dnb-modal__overlay--no-animation {
animation-delay: 0ms !important;
animation-duration: 0ms !important; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1968,11 +1968,11 @@ button.dnb-button::-moz-focus-inner {
from {
opacity: 0; }
to {
opacity: var(--modal-overlay-opacity); } }
opacity: 1; } }
@keyframes hide-modal-overlay {
from {
opacity: var(--modal-overlay-opacity); }
opacity: 1; }
to {
opacity: 0; } }
Expand Down Expand Up @@ -2334,8 +2334,7 @@ button.dnb-button::-moz-focus-inner {
:root {
--modal-z-index: 3000;
--modal-animation-duration: 300ms;
--modal-overlay-bg: black;
--modal-overlay-opacity: 0.32; }
--modal-overlay-bg: rgba(0, 0, 0, 0.32); }
html[data-dnb-modal-active] {
user-select: none;
Expand Down Expand Up @@ -2387,11 +2386,11 @@ html[data-dnb-modal-active] {
height: 100%;
background-color: var(--modal-overlay-bg); }
.dnb-modal-root__inner .dnb-modal__overlay {
animation: hide-modal-overlay var(--modal-animation-duration) ease-in-out forwards; }
animation: hide-modal-overlay var(--modal-animation-duration) ease-out forwards; }
.dnb-modal-root__inner:last-of-type .dnb-modal__overlay {
animation: show-modal-overlay var(--modal-animation-duration) ease-out forwards 0ms; }
animation: show-modal-overlay var(--modal-animation-duration) ease-out forwards; }
.dnb-modal-root__inner:last-of-type .dnb-modal__overlay--hide {
animation: hide-modal-overlay var(--modal-animation-duration) ease-in-out forwards; }
animation: hide-modal-overlay var(--modal-animation-duration) ease-out forwards; }
html[data-visual-test] .dnb-modal__overlay, .dnb-modal__overlay--no-animation {
animation-delay: 0ms !important;
animation-duration: 0ms !important; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@
opacity: 0;
}
to {
opacity: var(--modal-overlay-opacity);
opacity: 1;
}
}
@keyframes hide-modal-overlay {
from {
opacity: var(--modal-overlay-opacity);
opacity: 1;
}
to {
opacity: 0;
Expand Down
11 changes: 5 additions & 6 deletions packages/dnb-eufemia/src/components/modal/style/_modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
:root {
--modal-z-index: 3000;
--modal-animation-duration: 300ms;
--modal-overlay-bg: black;
--modal-overlay-opacity: 0.32;
--modal-overlay-bg: rgba(0, 0, 0, 0.32);
}

html[data-dnb-modal-active] {
Expand Down Expand Up @@ -84,17 +83,17 @@ html[data-dnb-modal-active] {
}

&-root__inner &__overlay {
animation: hide-modal-overlay var(--modal-animation-duration)
ease-in-out forwards;
animation: hide-modal-overlay var(--modal-animation-duration) ease-out
forwards;
}

&-root__inner:last-of-type &__overlay {
animation: show-modal-overlay var(--modal-animation-duration) ease-out
forwards 0ms;
forwards;

&--hide {
animation: hide-modal-overlay var(--modal-animation-duration)
ease-in-out forwards;
ease-out forwards;
}
}

Expand Down

0 comments on commit 86d875d

Please sign in to comment.