-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
add hideToast prop to authenticator #7129
add hideToast prop to authenticator #7129
Conversation
Codecov Report
@@ Coverage Diff @@
## main #7129 +/- ##
=======================================
Coverage 74.26% 74.26%
=======================================
Files 215 215
Lines 13470 13470
Branches 2645 2645
=======================================
Hits 10004 10004
Misses 3268 3268
Partials 198 198 Continue to review full report at Codecov.
|
Could this get reviewed please? Would be awesome to have 💪 |
Not sure if I'm supposed to randomly bug people for reviews sorry! @elorzafe @sammartinez @manueliglesias This is a pretty simple change. Could argue that it should be |
packages/amplify-ui-components/src/components/amplify-authenticator/amplify-authenticator.tsx
Outdated
Show resolved
Hide resolved
packages/amplify-ui-components/src/components/amplify-authenticator/amplify-authenticator.tsx
Outdated
Show resolved
Hide resolved
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.
Sorry about the late review! Just got some nits but looks good to me otherwise 👍
Thanks @wlee221! |
Thanks for taking this need on @Luke-Davies. I support @wlee221's feedback, and wanted to offer some context into past discussions around this need. The UI components are, as we know, powered by Web Components and often rely on "slots" for customizing individual components. What we didn't know at the time is if <AmplifyAuthenticator>
<!-- Default components here -->
<div slot="amplify-toast">
<!-- Nothing to see here! -->
</div>
</AmplifyAuthenticator> Do either of y'all know if this is better, worse, or possible? IIRC, the rationale for Again, I'm supportive of this PR to unblock customers! I just wanted to share where we left off in conversations in the past. |
Thanks for the context @ericclemmons. I had considered trying to implement this feature by introducing a slot and would absolutely support that solution if it is more in-keeping with the design choices made for the project so far. If a slot is introduced then I would suggest something other than For example; our app displays a modal for auth errors because we found that some customers were not seeing the toast on certain devices unless they happened to scroll to the top of the page. Currently, we're showing this modal as well as the toast (until we can hide the toast). Perhaps |
I agree, I just found #6479 as well, so we're not the only ones who've talked about this :D So, in terms of preference having fewer props would be preferential. Especially since a @wlee221 What are your thoughts on the matter? Do you prefer props vs. slots, and what name would you use? (Assuming it would work!) |
I can't believe I missed the slot approach! I just tested that using slots works as intended, so this is really up to what we want to do. I'm kind of divided on slots vs props though. If it were just for hiding toast, I would have argued that
And it's not clear what the code is trying to do on first glance. I think the purpose of hiding an element deviates from customization, which slot specializes in. That being said, customers are asking for toast customizations on #6479. Slots do well for covering both use cases, so I think slot is the best way to go. And I agree with @ericclemmons' comment that fewer props are preferential. So tldr; we should go with slots. For the slot name, I like |
@wlee221 @ericclemmons I believe we can close this one. |
Coming back to this following a discussion on #7601 ( |
@wlee221 One final change I wasn't sure of on this was whether to wrap Let me know if you think it's worth doing. |
I think this is a pretty simple optimization worth doing. As mentioned, I don't see a good reason for changing the |
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.
This LGTM 👍 Thanks a lot for your contribution throughout this!
This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Issue #, if available:
None
Description of changes:
Adds a property to the
amplify-authenticator
calledshowToastshideToast
which is defaulted tofalse
.Setting this to
true
will preventamplify-toast
from rendering whenTOAST_AUTH_ERROR_EVENT
events are raised on theUI_AUTH_CHANNEL
.This is useful if you want to roll your own alerting components for auth error messages.
React Example:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.