-
Notifications
You must be signed in to change notification settings - Fork 832
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
fix(toast): deduplicate toasts with same key #2657
Conversation
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/uber-ui-platform/baseweb/8hbcmffgn |
75e841c
to
c307f56
Compare
actually I was thinking we could implement a hidden counter in the toast config (e.g. something like this:
|
Visual changes were detected on this branch. Please review the following PR containing updated snapshots: foodforarabbit#1 |
Excited about this PR. I did not have the chance to test it out yet, but it seems like everything annoying about toasts fixed :) Nice work. |
About the A different approach to both of those could be a new prop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's heading in the right direction 👍
I agree that changing the autoHideDuration
is not sufficient, and the update count approach seems more appropriate. Another prop called resetAutoHideTimerOnReset
or similar can be added to control the behavior. If 'showing' a duplicate toast should it reset the timer by default, or the opposite? I personally am leaning towards reset.
Just a naming nitpick. |
c307f56
to
2eb7dd2
Compare
2eb7dd2
to
b00c849
Compare
b00c849
to
6c66764
Compare
caught this already :D |
🙄 ah good catch, typo |
3fb501c
to
9c8ed02
Compare
…deDuration from original toast
9c8ed02
to
b49e636
Compare
hehe well I'll leave it up to them to decide. I'm still new around here,
just fixing bugs and filling in gaps. Don't know what the long term plans
are yet - was going to finally get started looking over the figma tomorrow!
but I believe that if they are going to allow it at all, props on a toast
is the lesser evil compared to two ToasterContainers controlled by directly
by ref puppet strings xD
…On Tue, Jan 21, 2020 at 11:09 PM houmark ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/toast/toaster.js
<#2657 (comment)>:
> @@ -41,6 +41,15 @@ export class ToasterContainer extends React.Component<
constructor(props: ToasterPropsT) {
super(props);
+
+ if (__DEV__) {
+ if (toasterRef !== undefined) {
+ // eslint-disable-next-line no-console
+ console.warn(
+ 'A ToasterContainer already exists in your application. It is not recommended to have more than one ToasterContainer in an application.',
Also just thought if placement could be controlled by the toast itself
(the ToasterContainer prop can jsut be default like autoHideTimeout is)
that would cover your use case with a single ToasterContainer as well. It
shouldn't be too hard to sort toasts based on placement and render them
separately. But again, another time, another issue :)
I'd personally love to see that (in a different PR of course). It would
make it simpler and then this warning could be reintroduced and the old
behavior deprecated in the warning with a link to the documentation for
that new feature. But as you may read in the issue I created to ask for
this, it did not seem like this was a feature the Uber team wanted as it
was not good practice, but they may be more open to it now (as they had a
case where they helped someone implement it after I did my question)?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2657?email_source=notifications&email_token=AAR5OZZF24O4TNW62ZLXDIDQ67WKNA5CNFSM4KIXQPV2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCSSVM2A#discussion_r369398236>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAR5OZ2OXSH6YDIA74B5HYDQ67WKNANCNFSM4KIXQPVQ>
.
|
Visual changes were detected on this branch. Please review the following PR containing updated snapshots: foodforarabbit#1 |
I think this is good to land once VRT changes are resolved. Thanks for looking into the auto-hide issue and raising the some of the complexities with multiple containers. I'm open to start addressing the placement-by-toast feature. It's not a common pattern, but there's at least one application here that needs it |
test(vrt): update visual snapshots for toast-de-duplicate [skip ci]
Not sure what I need to do with the VRT xD I saw a pull request into my branch and merged it in, saw 3 pngs but not sure what I was looking for. |
It's kind of a side-effect of how we combine e2e tests and visual regression tests. In this case, the new screenshots look fine |
* fix(toast): deduplicate toasts with same key * fix(toast): add opt resetAutoHideTimerOnUpdate, update docs, immutable * fix(toast): fixed documentation and tests * fix(toast): addressed some code / wording issues * fix(toast): fixed issues in toast documentation, carry forward autoHideDuration from original toast * fix(toaster): add warning if another ToasterContainer detected * fix(toaster): removed warning for multiple ToastContainers * test(vrt): update visual snapshots for d19e600 [skip ci] Co-authored-by: UberOpenSourceBot <33560951+UberOpenSourceBot@users.noreply.github.com> Co-authored-by: Chase Starr <chasestarr@gmail.com>
Fixes #2333
Description
autoHideDuration
property is changed - we can avoid a deep comparison to figure out if a toast has changed or not. Might want to make this more explicit somehow - suggestions welcomeLayer
instead of creating a portal manually to the bodytoaster
utility and the same-key update situationScope