From 0ccd82c1d4d57c193751d3b1b471b612f5f22ed3 Mon Sep 17 00:00:00 2001 From: Sai Deepesh Date: Wed, 7 Jun 2023 19:29:36 +0530 Subject: [PATCH] [MM 22957] webapp a11y: fix sso btns focus issue (#23326) * make suggested changes * added form tag and removed event handler * fix snapshot --------- Co-authored-by: Mattermost Build --- .../login/__snapshots__/login.test.tsx.snap | 79 ++++++++-------- .../channels/src/components/login/login.tsx | 91 +++++++++---------- 2 files changed, 86 insertions(+), 84 deletions(-) diff --git a/webapp/channels/src/components/login/__snapshots__/login.test.tsx.snap b/webapp/channels/src/components/login/__snapshots__/login.test.tsx.snap index 88ed5da5c6..5f0c938d07 100644 --- a/webapp/channels/src/components/login/__snapshots__/login.test.tsx.snap +++ b/webapp/channels/src/components/login/__snapshots__/login.test.tsx.snap @@ -57,7 +57,6 @@ exports[`components/login/Login should match snapshot with base login 1`] = ` >

Log in

-
- -
- + +
- Forgot your password? - + + Forgot your password? + +
+
- -
+
diff --git a/webapp/channels/src/components/login/login.tsx b/webapp/channels/src/components/login/login.tsx index f72e7df0f0..68bf1c8b19 100644 --- a/webapp/channels/src/components/login/login.tsx +++ b/webapp/channels/src/components/login/login.tsx @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React, {useState, useEffect, useRef, useCallback} from 'react'; +import React, {useState, useEffect, useRef, useCallback, FormEvent} from 'react'; import {useIntl} from 'react-intl'; import {Link, useLocation, useHistory} from 'react-router-dom'; import {useSelector, useDispatch} from 'react-redux'; @@ -672,12 +672,6 @@ const Login = ({onCustomizeHeader}: LoginProps) => { setBrandImageError(true); }; - const onEnterKeyDown = (e: React.KeyboardEvent) => { - if (e.key === Constants.KeyCodes.ENTER[0]) { - preSubmit(e); - } - }; - const getCardTitle = () => { if (CustomDescriptionText) { return CustomDescriptionText; @@ -765,7 +759,6 @@ const Login = ({onCustomizeHeader}: LoginProps) => {

@@ -781,44 +774,50 @@ const Login = ({onCustomizeHeader}: LoginProps) => { /> )} {enableBaseLogin && ( -

- - - {(enableSignInWithUsername || enableSignInWithEmail) && ( -
- - {formatMessage({id: 'login.forgot', defaultMessage: 'Forgot your password?'})} - -
- )} - -
+
) => { + preSubmit(event as unknown as React.MouseEvent); + }} + > +
+ + + {(enableSignInWithUsername || enableSignInWithEmail) && ( +
+ + {formatMessage({id: 'login.forgot', defaultMessage: 'Forgot your password?'})} + +
+ )} + +
+
)} {enableBaseLogin && enableExternalSignup && (