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

Toast height calculation bug #133

Closed
danqing opened this issue Nov 17, 2021 · 7 comments · Fixed by #207 · May be fixed by russellcs/ft1-dating-app#176 or vAHiD55555/proxy-provider-converter#4
Closed

Toast height calculation bug #133

danqing opened this issue Nov 17, 2021 · 7 comments · Fixed by #207 · May be fixed by russellcs/ft1-dating-app#176 or vAHiD55555/proxy-provider-converter#4
Labels
bug Something isn't working

Comments

@danqing
Copy link

danqing commented Nov 17, 2021

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!)

@timolins timolins added the bug Something isn't working label Nov 24, 2021
@timolins
Copy link
Owner

timolins commented Jan 4, 2022

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.

@swiftyjam
Copy link

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

@alexfertel
Copy link

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

timolins added a commit that referenced this issue Jul 10, 2022
* Toast height will be re-calculated `onLayoutEffect` - #133
* Memoize height ref - #107 - inspired by #154
* Restructure handlers for better memoization

Not entirely happy with the internal API yet. Might need to rework.
@valdrin-t
Copy link

valdrin-t commented Aug 1, 2022

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} />

@timolins
Copy link
Owner

timolins commented Aug 1, 2022

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

@valdrin-t
Copy link

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

@liho00
Copy link

liho00 commented Aug 11, 2022

.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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment