paragon icon indicating copy to clipboard operation
paragon copied to clipboard

fix: `Toast` children prop type

Open rpenido opened this issue 1 year ago β€’ 7 comments

Description

This is a small fix of the typing for the children prop of the Toast component. This was generating some warnings in the frontend-app-course-authoring when the Toast was used with an Element instead of a string.

Example (from here):

<Toast show={blockFailed} onClose={hooks.nullMethod}>
  <FormattedMessage {...messages.couldNotLoadTextContext}
</Toast>

Deploy Preview

https://deploy-preview-3232--paragon-openedx.netlify.app/components/toast/

Merge Checklist

  • [x] If your update includes visual changes, have they been reviewed by a designer? Send them a link to the Netlify deploy preview, if applicable.
  • [x] Does your change adhere to the documented style conventions?
  • [x] Do any prop types have missing descriptions in the Props API tables in the documentation site (check deploy preview)?
  • [x] Were your changes tested using all available themes (see theme switcher in the header of the deploy preview, under the "Settings" icon)?
  • [x] Were your changes tested in the example app?
  • [x] Is there adequate test coverage for your changes?
  • [x] Consider whether this change needs to reviewed/QA'ed for accessibility (a11y). If so, please request an a11y review for the PR in the #wg-paragon Open edX Slack channel.

Post-merge Checklist

  • [ ] Verify your changes were released to NPM at the expected version.
  • [ ] If you'd like, share your contribution in #show-and-tell.
  • [ ] πŸŽ‰ πŸ™Œ Celebrate! Thanks for your contribution.

rpenido avatar Sep 11 '24 00:09 rpenido

Thanks for the pull request, @rpenido!

This repository is currently maintained by @openedx/paragon-working-group.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

:radio_button: Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
:radio_button: Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
:radio_button: Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

:bulb: As a result it may take up to several weeks or months to complete a review and merge your PR.

openedx-webhooks avatar Sep 11 '24 00:09 openedx-webhooks

Deploy Preview for paragon-openedx ready!

Built without sensitive environment variables

Name Link
Latest commit f6de16cb2df6ec5e08f4190bf37e2af44d47eb5e
Latest deploy log https://app.netlify.com/sites/paragon-openedx/deploys/66e1d0d73b2f900008faf980
Deploy Preview https://deploy-preview-3232--paragon-openedx.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Sep 11 '24 00:09 netlify[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 93.27%. Comparing base (a2d1a9d) to head (f6de16c). Report is 82 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3232   +/-   ##
=======================================
  Coverage   93.27%   93.27%           
=======================================
  Files         249      249           
  Lines        4401     4401           
  Branches     1033     1033           
=======================================
  Hits         4105     4105           
  Misses        290      290           
  Partials        6        6           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Sep 11 '24 00:09 codecov[bot]

@rpenido Thanks for fixing this. Is it ready for review?

bradenmacdonald avatar Sep 11 '24 16:09 bradenmacdonald

Yes! It is ready now.

rpenido avatar Sep 11 '24 16:09 rpenido

@bradenmacdonald Fixed!

rpenido avatar Sep 11 '24 19:09 rpenido

@rpenido This is going to require some more input while we decide whether Toast should allow arbitrary components as children or not: https://openedx.slack.com/archives/C02NR285KV4/p1726077388682079

bradenmacdonald avatar Sep 11 '24 20:09 bradenmacdonald

@rpenido @bradenmacdonald is this pull request still in progress?

mphilbrick211 avatar Feb 24 '25 22:02 mphilbrick211

Apparently this was discussed in this Paragon Working Group meeting and I didn't realize. @adamstankiewicz found and summarized it for me:

[question] Perhaps the reason it’s a string is to help indicate that nodes such a CTAs/hyperlinks should be done through the action prop?

I believe the primary design concern without some usage guideline constraint (that would easily not be followed) is that actions in toasts become non-standard if providing an open slot to put any node vs. restricting it to action as intended (for consistent design pattern).

It could be worth thinking about it more from a design pov, understanding the use cases further, and offering specific props around title, icon, etc. For example, if we begin allowing titles/icons in toasts per the above screenshot, we would ideally do so in way that provides standard defaults around title styles, icon sizes, etc. vs leaving those design decisions up to each individual use case (e.g., avoid different implementations of toasts with different title styles, etc). Regarding lists in toasts, I'm not sure that's a pattern we'd necessarily want to encourage, since toast notifications are intended to be fairly brief with simple messaging. Understanding/articulating the real product use cases further and making the Toast more flexible, though still with guardrails to maintain consistency across the platform, would be preferable imho. Though, if we are comfortable with node, I'd recommend at least putting a usage guideline blurb under the "With button" section on the docs site for Toast that encourages the use of action vs. children for button-like actions.

bradenmacdonald avatar Feb 24 '25 23:02 bradenmacdonald

@rpenido Is it just <FormattedMessage /> that we need to include here? If so, can it just be replaced with intl.formatMessage(...) and keep the typing as-is ?

bradenmacdonald avatar Feb 24 '25 23:02 bradenmacdonald

@rpenido Is it just <FormattedMessage /> that we need to include here? If so, can it just be replaced with intl.formatMessage(...) and keep the typing as-is ?

@bradenmacdonald Actually, we also have a use case where we draw an Icon inside the toast (which is covered by the discussion):

image

This is the primary way we use the Toast on the Library Authoring pages.

https://github.com/openedx/frontend-app-authoring/blob/63caf098a57db870341166c26db182564d16377f/src/generic/processing-notification/index.jsx#L8-L23

rpenido avatar Feb 25 '25 18:02 rpenido

@rpenido Oh right, sorry I forgot that.

bradenmacdonald avatar Feb 25 '25 18:02 bradenmacdonald

If people aren't in favor of allowing arbitrary children anytime soon, another option then could be to add an icon prop.

bradenmacdonald avatar Feb 25 '25 18:02 bradenmacdonald

I like the icon prop idea. That is definitely an understandable use case, and having an easy way to add an icon to a notification seems like a good feature. It would also be quite easy to add an icon-in-toast example to the docs site.

brian-smith-tcril avatar Feb 26 '25 13:02 brian-smith-tcril

Closing this since we are moving to add a Icon props.

rpenido avatar Mar 10 '25 19:03 rpenido