Skip to content

Commit

Permalink
PWA-3078::The user is unable to get any message once the account is c… (
Browse files Browse the repository at this point in the history
#4131)

* PWA-3078::The user is unable to get any message once the account is created and they are logged in

* PWA-3078::The user is unable to get any message once the account is created and they are logged in

* PWA-3078::Resolved lint issues

* PWA-3078::Formatted the screen reader message

* PWA-3078::Resolved test case

* PWA-3078::Resolved test case

* PWA-3078::Formatted the code

---------

Co-authored-by: Aanchal Pawar <97873570+glo82145@users.noreply.github.com>
  • Loading branch information
glo80771 and glo82145 committed Oct 4, 2023
1 parent 0c3cd48 commit 3e20773
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ const initialProps = {
getCartDetailsQuery: 'getCartDetailsQuery',
setDefaultUsername: jest.fn(),
showCreateAccount: jest.fn(),
showForgotPassword: jest.fn()
showForgotPassword: jest.fn(),
handleTriggerClick: jest.fn()
};

const clearCacheData = jest.fn();
Expand Down
5 changes: 4 additions & 1 deletion packages/peregrine/lib/talons/SignIn/useSignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useEventingContext } from '../../context/eventing';

export const useSignIn = props => {
const {
handleTriggerClick,
getCartDetailsQuery,
setDefaultUsername,
showCreateAccount,
Expand Down Expand Up @@ -66,6 +67,7 @@ export const useSignIn = props => {
const handleSubmit = useCallback(
async ({ email, password }) => {
setIsSigningIn(true);
handleTriggerClick();
try {
// Get source cart id (guest cart id).
const sourceCartId = cartId;
Expand Down Expand Up @@ -142,7 +144,8 @@ export const useSignIn = props => {
fetchUserDetails,
getCartDetails,
fetchCartDetails,
dispatch
dispatch,
handleTriggerClick
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports[`it renders a loading indicator when appropriate 1`] = `
</span>
<span
aria-atomic="true"
aria-label="Toggle My Account Menu"
aria-label="Hiundefined"
aria-live="polite"
className="text"
>
Expand Down
11 changes: 7 additions & 4 deletions packages/venia-ui/lib/components/AccountChip/accountChip.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ const AccountChip = props => {
const classes = useStyle(defaultClasses, props.classes);
const { formatMessage } = useIntl();

const ariaLabelMyMenu = formatMessage({
id: 'accountTrigger.ariaLabelMyMenu',
defaultMessage: 'Toggle My Account Menu'
});
const ariaLabelMyMenu =
currentUser != null
? formatMessage({
id: 'Hi' + currentUser.firstname,
defaultMessage: 'Hi' + currentUser.firstname
})
: '';

const ariaLabel = isUserSignedIn ? ariaLabelMyMenu : '';

Expand Down
7 changes: 6 additions & 1 deletion packages/venia-ui/lib/components/AccountMenu/accountMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import ForgotPassword from '../ForgotPassword';
import defaultClasses from './accountMenu.module.css';

const AccountMenu = React.forwardRef((props, ref) => {
const { accountMenuIsOpen, setAccountMenuIsOpen } = props;
const {
handleTriggerClick,
accountMenuIsOpen,
setAccountMenuIsOpen
} = props;
const talonProps = useAccountMenu({
accountMenuIsOpen,
setAccountMenuIsOpen
Expand Down Expand Up @@ -67,6 +71,7 @@ const AccountMenu = React.forwardRef((props, ref) => {
default: {
dropdownContents = (
<SignIn
handleTriggerClick={handleTriggerClick}
classes={{
modal_active: classes.loading
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Array [
</div>,
<require('../AccountMenu')
accountMenuIsOpen={false}
handleTriggerClick={[MockFunction handleTriggerClick]}
/>,
]
`;
1 change: 1 addition & 0 deletions packages/venia-ui/lib/components/Header/accountTrigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const AccountTrigger = props => {
</div>
<Suspense fallback={null}>
<AccountMenu
handleTriggerClick={handleTriggerClick}
ref={accountMenuRef}
accountMenuIsOpen={accountMenuIsOpen}
setAccountMenuIsOpen={setAccountMenuIsOpen}
Expand Down
2 changes: 2 additions & 0 deletions packages/venia-ui/lib/components/SignIn/signIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import GoogleRecaptcha from '../GoogleReCaptcha';
const SignIn = props => {
const classes = useStyle(defaultClasses, props.classes);
const {
handleTriggerClick,
setDefaultUsername,
showCreateAccount,
showForgotPassword,
Expand All @@ -27,6 +28,7 @@ const SignIn = props => {

const { formatMessage } = useIntl();
const talonProps = useSignIn({
handleTriggerClick,
getCartDetailsQuery: GET_CART_DETAILS_QUERY,
setDefaultUsername,
showCreateAccount,
Expand Down

0 comments on commit 3e20773

Please sign in to comment.