From 07f00fd7d21dcc36e83fae70445ff4d5005ff045 Mon Sep 17 00:00:00 2001
From: Ajay Bura <32841439+ajbura@users.noreply.github.com>
Date: Thu, 18 Jan 2024 11:30:39 +0530
Subject: [PATCH] add focus trap & step count in UIA stages
---
.../auth/register/PasswordRegisterForm.tsx | 135 ++++++++++++------
1 file changed, 91 insertions(+), 44 deletions(-)
diff --git a/src/app/pages/auth/register/PasswordRegisterForm.tsx b/src/app/pages/auth/register/PasswordRegisterForm.tsx
index aae95d21b6..488e3eaec6 100644
--- a/src/app/pages/auth/register/PasswordRegisterForm.tsx
+++ b/src/app/pages/auth/register/PasswordRegisterForm.tsx
@@ -2,13 +2,20 @@ import {
Box,
Button,
Checkbox,
+ Chip,
+ Icon,
+ IconButton,
+ Icons,
Input,
Overlay,
OverlayBackdrop,
OverlayCenter,
Spinner,
Text,
+ Tooltip,
+ TooltipProvider,
color,
+ config,
} from 'folds';
import React, {
ChangeEventHandler,
@@ -28,6 +35,7 @@ import {
UIAFlow,
createClient,
} from 'matrix-js-sdk';
+import FocusTrap from 'focus-trap-react';
import { PasswordInput } from '../../../components/password-input/PasswordInput';
import {
getLoginTermUrl,
@@ -35,7 +43,7 @@ import {
hasStageInFlows,
requiredStageInFlows,
} from '../../../utils/matrix-uia';
-import { useUIAFlow, useUIAParams } from '../../../hooks/useUIAFlows';
+import { useUIACompleted, useUIAFlow, useUIAParams } from '../../../hooks/useUIAFlows';
import { AsyncState, AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
import { useAutoDiscoveryInfo } from '../../../hooks/useAutoDiscoveryInfo';
import { RegisterError, RegisterResult, register, useRegisterComplete } from './registerUtil';
@@ -140,6 +148,7 @@ function RegisterUIAFlow({
registerEmail,
onRegister,
}: RegisterUIAFlowProps) {
+ const completed = useUIACompleted(authData);
const { getStageToComplete } = useUIAFlow(authData, flow);
const stageToComplete = getStageToComplete();
@@ -157,55 +166,93 @@ function RegisterUIAFlow({
[onRegister, formData]
);
- const handleChange = useCallback(() => {
+ const handleCancel = useCallback(() => {
window.location.reload();
}, []);
if (!stageToComplete) return null;
return (
}>
-
- {stageToComplete.type === AuthType.RegistrationToken && (
-
- )}
- {stageToComplete.type === AuthType.Terms && (
-
- )}
- {stageToComplete.type === AuthType.Recaptcha && (
-
- )}
- {stageToComplete.type === AuthType.Email && (
-
- )}
- {stageToComplete.type === AuthType.Dummy && (
-
- )}
-
+
+
+
+ {stageToComplete.type === AuthType.RegistrationToken && (
+
+ )}
+ {stageToComplete.type === AuthType.Terms && (
+
+ )}
+ {stageToComplete.type === AuthType.Recaptcha && (
+
+ )}
+ {stageToComplete.type === AuthType.Email && (
+
+ )}
+ {stageToComplete.type === AuthType.Dummy && (
+
+ )}
+
+
+
+ {`Step ${completed.length + 1}/${
+ flow.stages.length
+ }`}
+
+
+ Exit
+
+ }
+ position="Top"
+ >
+ {(anchorRef) => (
+
+
+
+ )}
+
+
+
+
);
}