Skip to content

Commit 237a2dc

Browse files
committed
feat: added transition flag to avoid skip steps if doubleclick
1 parent 6543325 commit 237a2dc

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/data/statementsCategories.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
{
1616
"id": "Disability",
17-
"name": "My experience as someone with a disability or long term condition"
17+
"name": "Disability & Long-term Conditions"
1818
},
1919
{
2020
"id": "Colleague_Sharing",

src/features/wizard/components/StatementWizard.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ const StatementWizard: React.FC<StatementWizardProps> = ({
6565
category: '',
6666
});
6767
const [isSubmitting, setIsSubmitting] = useState(false);
68+
// Add a flag to prevent rapid multiple step transitions
69+
const [isTransitioning, setIsTransitioning] = useState(false);
6870

6971
// Initialize default values based on whether this is a preset or custom statement
7072
useEffect(() => {
@@ -123,11 +125,27 @@ const StatementWizard: React.FC<StatementWizardProps> = ({
123125
};
124126

125127
const goNext = () => {
126-
if (currentStepIndex < steps.length - 1) {
127-
setCurrentStepIndex((prev) => prev + 1);
128-
} else {
129-
handleComplete();
128+
// Check if we're already in the middle of a transition
129+
if (isTransitioning) {
130+
return; // Prevent multiple rapid transitions
130131
}
132+
133+
// Set transitioning flag to prevent additional advances
134+
setIsTransitioning(true);
135+
136+
// Add a small delay to prevent double-click issues
137+
setTimeout(() => {
138+
if (currentStepIndex < steps.length - 1) {
139+
setCurrentStepIndex((prev) => prev + 1);
140+
} else {
141+
handleComplete();
142+
}
143+
144+
// Reset transition flag after a slightly longer delay
145+
setTimeout(() => {
146+
setIsTransitioning(false);
147+
}, 300);
148+
}, 200); // 200ms delay to prevent step skipping
131149
};
132150

133151
const goBack = () => {

0 commit comments

Comments
 (0)