Fix toast positioning inside popups to align with the "Notifications" positioning option (#4506) * fix: adjust toast container positioning in popups to match core toastr behavior Fixes #4490 * Fix misplaced element role * Hide toast container while opening animation is running * fix: update toast role from alert to status --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
Signed| @@ -26,7 +26,6 @@ dialog { | |||
| 26 | 26 | ||
| 27 | /* Fix weird animation issue with font-scaling during popup open */ | 27 | /* Fix weird animation issue with font-scaling during popup open */ |
| 28 | backface-visibility: hidden; | 28 | backface-visibility: hidden; |
| 29 | transform: translateZ(0); | ||
| 30 | -webkit-font-smoothing: subpixel-antialiased; | 29 | -webkit-font-smoothing: subpixel-antialiased; |
| 31 | 30 | ||
| 32 | /* Variables setup */ | 31 | /* Variables setup */ |
| @@ -93,6 +92,11 @@ dialog { | |||
| 93 | animation: fade-in var(--popup-animation-speed) ease-in-out; | 92 | animation: fade-in var(--popup-animation-speed) ease-in-out; |
| 94 | } | 93 | } |
| 95 | 94 | ||
| 95 | /* Fix toast container snapping into the backdrop while the animation is running */ | ||
| 96 | .popup[opening] #toast-container { | ||
| 97 | visibility: hidden; | ||
| 98 | } | ||
| 99 | |||
| 96 | /* Open state of the dialog */ | 100 | /* Open state of the dialog */ |
| 97 | .popup[open] { | 101 | .popup[open] { |
| 98 | color: var(--SmartThemeBodyColor); | 102 | color: var(--SmartThemeBodyColor); |
| @@ -118,17 +122,30 @@ body.no-blur .popup[open]::backdrop { | |||
| 118 | animation: fade-out var(--popup-animation-speed) ease-in-out; | 122 | animation: fade-out var(--popup-animation-speed) ease-in-out; |
| 119 | } | 123 | } |
| 120 | 124 | ||
| 121 | .popup #toast-container { | 125 | /* Edge inset to match Toastr default spacing */ |
| 122 | /* Fix toastr in dialogs by actually placing it at the top of the screen via transform */ | 126 | :root { |
| 123 | height: 100dvh; | 127 | --toast-edge: 12px; |
| 124 | top: calc(50% + var(--topBarBlockSize)); | 128 | } |
| 125 | left: 50%; | ||
| 126 | transform: translate(-50%, -50%); | ||
| 127 | 129 | ||
| 128 | /* Fix text align, popups are centered by default. toasts should not. */ | 130 | .popup #toast-container { |
| 131 | /* Popups are centered by default; toasts should not be */ | ||
| 129 | text-align: left; | 132 | text-align: left; |
| 130 | } | 133 | } |
| 131 | 134 | ||
| 135 | /* Per-position position adjustments caused by the top bar, inside the popup */ | ||
| 136 | .popup #toast-container.toast-top-left { | ||
| 137 | top: calc(var(--toast-edge) + var(--topBarBlockSize)); | ||
| 138 | } | ||
| 139 | |||
| 140 | .popup #toast-container.toast-top-center { | ||
| 141 | /* toastr in core does not have a top offset on center, so we don't do that either in popups */ | ||
| 142 | top: var(--topBarBlockSize); | ||
| 143 | } | ||
| 144 | |||
| 145 | .popup #toast-container.toast-top-right { | ||
| 146 | top: calc(var(--toast-edge) + var(--topBarBlockSize)); | ||
| 147 | } | ||
| 148 | |||
| 132 | .popup-crop-wrap { | 149 | .popup-crop-wrap { |
| 133 | margin: 10px auto; | 150 | margin: 10px auto; |
| 134 | max-height: 75vh; | 151 | max-height: 75vh; |
| @@ -64,8 +64,8 @@ const a11yRules = { | |||
| 64 | [toolbarSelectors]: (element) => { | 64 | [toolbarSelectors]: (element) => { |
| 65 | element.setAttribute('role', 'toolbar'); | 65 | element.setAttribute('role', 'toolbar'); |
| 66 | }, | 66 | }, |
| 67 | '#toast-container .toast-message': (element) => { | 67 | '#toast-container .toast': (element) => { |
| 68 | element.setAttribute('role', 'alert'); | 68 | element.setAttribute('role', 'status'); |
| 69 | }, | 69 | }, |
| 70 | }; | 70 | }; |
| 71 | 71 | ||