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

Added warnings to the PageContentWide component #3127

Merged
merged 4 commits into from
Jul 5, 2023

Conversation

chloe0592
Copy link
Contributor

@chloe0592 chloe0592 commented Jul 4, 2023

The PageContentWide doesn't throw a warning when more children are passed as props.
For example if 3 are passed, it only renders first 2 children and it goes unnoticed that 3rd component is not rendered and why is that the case.

In this PR we cover 2 possible scenarios when the warning is shown:

  1. There's 1 column and more than 1 child.
  2. There's 1/1 or 2/1 columns and more than 2 children.

This PR closes - #3126.

@chloe0592 chloe0592 requested review from jaikumar-tj and a team July 4, 2023 11:00
@chloe0592 chloe0592 self-assigned this Jul 4, 2023
@changeset-bot
Copy link

changeset-bot bot commented Jul 4, 2023

🦋 Changeset detected

Latest commit: c7557ec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 35 packages
Name Type
@commercetools-frontend/application-components Patch
@commercetools-local/visual-testing-app Patch
@commercetools-frontend/application-shell Patch
@commercetools-frontend/codemod Patch
@commercetools-frontend/mc-scripts Patch
@commercetools-applications/merchant-center-template-starter-typescript Patch
@commercetools-applications/merchant-center-template-starter Patch
@commercetools-local/playground Patch
@commercetools-website/components-playground Patch
@commercetools-frontend/cypress Patch
@commercetools-backend/eslint-config-node Patch
@commercetools-backend/express Patch
@commercetools-backend/loggers Patch
@commercetools-frontend/actions-global Patch
@commercetools-frontend/application-config Patch
@commercetools-frontend/application-shell-connectors Patch
@commercetools-frontend/assets Patch
@commercetools-frontend/babel-preset-mc-app Patch
@commercetools-frontend/browser-history Patch
@commercetools-frontend/constants Patch
@commercetools-frontend/create-mc-app Patch
@commercetools-frontend/eslint-config-mc-app Patch
@commercetools-frontend/i18n Patch
@commercetools-frontend/jest-preset-mc-app Patch
@commercetools-frontend/jest-stylelint-runner Patch
@commercetools-frontend/l10n Patch
@commercetools-frontend/mc-dev-authentication Patch
@commercetools-frontend/mc-html-template Patch
@commercetools-frontend/notifications Patch
@commercetools-frontend/permissions Patch
@commercetools-frontend/react-notifications Patch
@commercetools-frontend/sdk Patch
@commercetools-frontend/sentry Patch
@commercetools-frontend/url-utils Patch
@commercetools-website/custom-applications Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jul 4, 2023

Deploy preview for merchant-center-application-kit ready!

✅ Preview
https://merchant-center-application-bwq72oclh-commercetools.vercel.app
https://appkit-sha-a4f18e806e8b54b9af81a0f4faf9e7e9d71d3631.commercetools.vercel.app
https://appkit-pr-3127.commercetools.vercel.app

Built with commit c7557ec.
This pull request is being automatically deployed with vercel-action

Copy link
Contributor

@jaikumar-tj jaikumar-tj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fixup. Just curious, does useWarning simply show a console warning or does it throw an error and prevent the developer from making mistake?

@chloe0592
Copy link
Contributor Author

Thanks for the quick fixup. Just curious, does useWarning simply show a console warning or does it throw an error and prevent the developer from making mistake?

@jaikumar-tj yes, exactly it'll show a warning in the console, it doesn’t throw an error. It will be looking like this.
Screenshot 2023-07-04 at 14 00 50

@CarlosCortizasCT
Copy link
Contributor

Thanks for the quick fixup. Just curious, does useWarning simply show a console warning or does it throw an error and prevent the developer from making mistake?

@jaikumar-tj yes, exactly it'll show a warning in the console, it doesn’t throw an error. It will be looking like this. Screenshot 2023-07-04 at 14 00 50

@jaikumar-tj we decided to follow @tdeekens advice of using a warning.

Bear in mind this will use a console.warn which should make the MC frontend consuming component tests to fail.

Copy link
Contributor

@ddouglasz ddouglasz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🫶🏻
Just tiny observations


useWarning(
props.columns !== '1' || !Boolean(rightChild),
props.columns === '1' && childrenCount > 1,
'PageContentWide: This component only renders its first children when using a single column but you provided more that one.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'PageContentWide: This component only renders its first children when using a single column but you provided more that one.'
'PageContentWide: This component only renders its first children when using a single column but you provided more than one.'

'PageContentWide: This component only renders its first children when using a single column but you provided more that one.'
);

useWarning(
props.columns !== '1' && childrenCount > 2,
'PageContentWide: This component only renders its first two children when using a two columns layout but you provided more that two.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'PageContentWide: This component only renders its first two children when using a two columns layout but you provided more that two.'
'PageContentWide: This component only renders its first two children when using a two columns layout but you provided more than two.'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! 🦅 Thanks - c7557ec.

Copy link
Contributor

@CarlosCortizasCT CarlosCortizasCT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@chloe0592 chloe0592 merged commit 0918b46 into main Jul 5, 2023
@chloe0592 chloe0592 deleted the kl-pageContentWide-warning branch July 5, 2023 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants