react-hot-toast icon indicating copy to clipboard operation
react-hot-toast copied to clipboard

BUG: Custom ToastBar makes 'bottom-center' position to slide from top instead of sliding from bottom

Open Puspendert opened this issue 3 years ago • 4 comments

[BUG REPORT]

I followed the docs example for adding a dismiss button. The prop set on Toaster is position="bottom-center", and toast does appear on the button center but the animation gets disturbed. Ideally bottom-center toast slide from the bottom but it is sliding from the top.

Here is a CodeSandbox

https://user-images.githubusercontent.com/16055344/123509181-9bf41a00-d691-11eb-943c-58e97b4070f0.mov

Puspendert avatar Jun 26 '21 09:06 Puspendert

Thanks for reporting. By default, the Toaster passes its position to the ToastBar via the position prop. This does not happen automatically when rolling your own.

A quick fix would be to add your current position to your ToastBar manually:

<ToastBar position="bottom-center"/>

This could be solved by passing it down via a React Context. I'll take this into consideration for future releases.

timolins avatar Jul 01 '21 17:07 timolins

A quick fix would be to add your current position to your ToastBar manually:

<ToastBar position="bottom-center"/>

@timolins Thanks for reply. I already tried that before reporting the bug. I came here after reading the documentation. But <ToastBar position="bottom-center"/> displays toatbar at the top, not bottom. I have changed this into the codesandbox, please verify.

Puspendert avatar Jul 03 '21 10:07 Puspendert

The position prop on the ToastBar is only used to apply the correct animation direction, not for the positioning itself.

You'd have to set the position on the Toaster as well.

timolins avatar Jul 04 '21 07:07 timolins