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

Toast height calculation bug

Open danqing opened this issue 4 years ago • 6 comments
trafficstars

Example: https://codesandbox.io/s/react-hot-toast-responsive-position-forked-64f33?file=/src/App.js

Screen Shot 2021-11-17 at 3 38 38 PM

When you use the toast ID to change one toast to another (e.g. from loading to success), sometimes the height of the toast is off. I think it's because it's not updating the height of the toast container when the content changed.

(As always, thank you for this great lib!)

danqing avatar Nov 17 '21 20:11 danqing

Great find, this is indeed a bug. The height of each toast is currently only measured on mount. The fix requires a bit of a refactoring, I will have a closer look when I get to it.

timolins avatar Jan 04 '22 14:01 timolins

Hey! Hows the progress on this @timolins ? ❤️

swiftyjam avatar Feb 02 '22 12:02 swiftyjam

Not sure if this is appropriate, but it would be very nice if this got fixed! Thanks for an awesome lib!

alexfertel avatar Feb 08 '22 17:02 alexfertel

Is there a way to force recalculation of the heights? I'm getting the same issue with toast.custom where the custom toaster can expand/shrink. Edit: Or perhaps change the custom toaster parent style?

Edit2: I managed to find a fix, by overwriting the className of the container and the children:

.wrapper {
  display: flex;
  flex-direction: column;
}
.wrapper > div {
  position: relative !important;
  transform: translateY(0) !important;
}
<Toaster containerClassName={style.wrapper} />

valdrin-t avatar Aug 01 '22 08:08 valdrin-t

@valdrin-t Not in the current version. This should be fixed with #207. Trying to get this out soon.

timolins avatar Aug 01 '22 09:08 timolins

Cool! I didn't notice the PR was still open, I thought it was merged.

valdrin-t avatar Aug 01 '22 09:08 valdrin-t

.wrapper {
  display: flex;
  flex-direction: column;
}
.wrapper > div {
  position: relative !important;
  transform: translateY(0) !important;
}

this method working, however dismissing the toast will be delay, have to use toast.remove to remove the toast, thus, this will also causing the animation of remove toast gone...

but for my case should be fine with this method. thanks!

liho00 avatar Aug 11 '22 08:08 liho00