mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-05 02:52:50 -05:00
fix: requried questions being skipped (#6506)
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
This commit is contained in:
committed by
GitHub
parent
fdba260301
commit
557f14bab8
@@ -769,7 +769,7 @@
|
||||
"check_out_the_docs": "Check out the docs.",
|
||||
"dive_into_the_docs": "Dive into the docs.",
|
||||
"does_your_widget_work": "Does your widget work?",
|
||||
"environment_id": "Your EnvironmentId",
|
||||
"environment_id": "Your Environment ID",
|
||||
"environment_id_description": "This id uniquely identifies this Formbricks environment.",
|
||||
"environment_id_description_with_environment_id": "Used to identify the correct environment: {environmentId} is yours.",
|
||||
"formbricks_sdk": "Formbricks SDK",
|
||||
|
||||
@@ -769,7 +769,7 @@
|
||||
"check_out_the_docs": "Consulte a documentação.",
|
||||
"dive_into_the_docs": "Mergulhe na documentação.",
|
||||
"does_your_widget_work": "O seu widget funciona?",
|
||||
"environment_id": "O seu EnvironmentId",
|
||||
"environment_id": "O Seu ID de Ambiente",
|
||||
"environment_id_description": "Este id identifica de forma única este ambiente Formbricks.",
|
||||
"environment_id_description_with_environment_id": "Usado para identificar o ambiente correto: {environmentId} é o seu.",
|
||||
"formbricks_sdk": "SDK Formbricks",
|
||||
|
||||
@@ -769,7 +769,7 @@
|
||||
"check_out_the_docs": "Consultați documentația.",
|
||||
"dive_into_the_docs": "Accesați documentația.",
|
||||
"does_your_widget_work": "Funcționează widgetul dvs.?",
|
||||
"environment_id": "ID-ul Mediului Dvs.",
|
||||
"environment_id": "ID-ul mediului tău",
|
||||
"environment_id_description": "Acest id identifică în mod unic acest mediu Formbricks.",
|
||||
"environment_id_description_with_environment_id": "Folosit pentru a identifica mediul corect: {environmentId} este al tău.",
|
||||
"formbricks_sdk": "SDK Formbricks",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ButtonHTMLAttributes, useRef } from "preact/compat";
|
||||
import { useCallback, useEffect } from "preact/hooks";
|
||||
import { useCallback, useEffect, useState } from "preact/hooks";
|
||||
|
||||
interface SubmitButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
buttonLabel?: string;
|
||||
@@ -18,18 +18,35 @@ export function SubmitButton({
|
||||
...props
|
||||
}: SubmitButtonProps) {
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const [isProcessing, setIsProcessing] = useState(false);
|
||||
|
||||
// throttle the button submit to prevent multiple submissions
|
||||
// works by setting a timeout to reset the isProcessing state
|
||||
// TODO: Refactor
|
||||
useEffect(() => {
|
||||
if (isProcessing) {
|
||||
const timer = setTimeout(() => {
|
||||
setIsProcessing(false);
|
||||
}, 300);
|
||||
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
};
|
||||
}
|
||||
}, [isProcessing]);
|
||||
|
||||
const handleKeyDown = useCallback(
|
||||
(event: KeyboardEvent) => {
|
||||
if ((event.metaKey || event.ctrlKey) && event.key === "Enter" && !disabled) {
|
||||
if ((event.metaKey || event.ctrlKey) && event.key === "Enter" && !disabled && !isProcessing) {
|
||||
event.preventDefault();
|
||||
setIsProcessing(true);
|
||||
const button = buttonRef.current;
|
||||
if (button) {
|
||||
button.click();
|
||||
}
|
||||
}
|
||||
},
|
||||
[disabled]
|
||||
[disabled, isProcessing]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user