Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

fix: store notices always shows as an error type #11768 #11932

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

agung2001
Copy link
Contributor

@agung2001 agung2001 commented Nov 24, 2023

What

This PR will fix #11768
Reviewer : @opr

Why

There's an issue with the store-notice-container when you try to create the container
it always shows an error type, for example, if you run

wp.data.dispatch('core/notices').createSuccessNotice( 'This is a success message, it should show in green!', { context: 'wc/cart' } )

in the web dev console in the cart/checkout block page, it'll show
Screenshot 2023-11-24 at 09 15 27

what we want is something like
Screenshot 2023-11-24 at 10 25 10

you can find more detail within the issue #11768

the issue is due to :

  • noticeProps status is set to error instead of using status variable

so to fix this we need to change the noticeProps to something like this :

const noticeProps: Omit<NoticeBannerProps, 'children'> & {
    key: string;
} = {
    key: `store-notice-${status}`,
    status,
    onRemove: () => {
        noticeGroup.forEach((notice) => {
            removeNotice(notice.id, notice.context);
        });
    },
};

This PR will affect cart & checkout block page that uses the StoreNotices component

Testing Instructions

Steps to reproduce the behavior:

  1. Go to the Cart block.
  2. In the web dev console type: wp.data.dispatch('core/notices').createSuccessNotice( 'This is a success message, it should show in green!', { context: 'wc/cart' } )
  3. See the "success" notice display in green.
  • Do not include in the Testing Notes
  • Should be tested by the development team exclusively

Screenshots or screencast

Before After
Screenshot 2023-11-24 at 09 15 27 Screenshot 2023-11-24 at 10 25 10

WooCommerce Visibility

Required:

  • WooCommerce Core
  • Feature plugin
  • Experimental
  • N/A

Checklist

Required:

  • This PR has either a [type] label or a [skip-changelog] label.
  • This PR is assigned to a milestone.

Conditional:

  • This PR has a UI change and has been cross-browser tested at different viewport sizes on both the frontend and in the editor.
  • This PR has a changelog description (if [skip-changelog] label is not present).
  • This PR adds/removes a feature flag & I've updated this doc.
  • This PR adds/removes an experimental interfaces, and I've updated this doc.
  • This PR has been accessibility tested.
  • This PR has had any necessary documentation added/updated.

Changelog

Ensure the correct styling is applied based on notice type when displaying StoreNotice components.

Copy link
Contributor

@opr opr left a comment

Choose a reason for hiding this comment

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

Hey @agung2001 thanks a lot for working on this! I've made a small change to the testing instructions in your PR body, and I moved the section originally below the changelog into the "Why" section.

I tested this and it works well. I'll just run CI in a separate PR then merge

Thank you for contributing to WC Blocks! 🙏🏼

@opr opr added the type: bug The issue/PR concerns a confirmed bug. label Nov 27, 2023
@opr
Copy link
Contributor

opr commented Nov 27, 2023

CI Ran in #11951

@opr opr merged commit 1717221 into woocommerce:trunk Nov 27, 2023
29 of 37 checks passed
@agung2001 agung2001 deleted the issue-#11768 branch November 27, 2023 21:48
@Aljullu Aljullu added this to the 11.7.0 milestone Dec 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug The issue/PR concerns a confirmed bug. type: community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store notices container always shows as an error
3 participants