fix: resolved disabled captcha click.

This commit is contained in:
Arsalan 2022-03-22 12:22:39 +05:30
parent f2ea8b1838
commit bef9d2d81b
2 changed files with 7 additions and 3 deletions

View File

@ -303,7 +303,7 @@ interface ButtonComponentProps extends ComponentProps {
function RecaptchaV2Component( function RecaptchaV2Component(
props: { props: {
children: any; children: any;
onClick?: (event: React.MouseEvent<HTMLElement>) => void; isDisabled?: boolean;
recaptchaType?: RecaptchaType; recaptchaType?: RecaptchaType;
handleError: (event: React.MouseEvent<HTMLElement>, error: string) => void; handleError: (event: React.MouseEvent<HTMLElement>, error: string) => void;
} & RecaptchaProps, } & RecaptchaProps,
@ -314,6 +314,7 @@ function RecaptchaV2Component(
props.handleRecaptchaV2Loading && props.handleRecaptchaV2Loading(isloading); props.handleRecaptchaV2Loading && props.handleRecaptchaV2Loading(isloading);
}; };
const handleBtnClick = async (event: React.MouseEvent<HTMLElement>) => { const handleBtnClick = async (event: React.MouseEvent<HTMLElement>) => {
if (props.isDisabled) return;
if (isInvalidKey) { if (isInvalidKey) {
// Handle incorrent google recaptcha site key // Handle incorrent google recaptcha site key
props.handleError(event, createMessage(GOOGLE_RECAPTCHA_KEY_ERROR)); props.handleError(event, createMessage(GOOGLE_RECAPTCHA_KEY_ERROR));
@ -352,7 +353,7 @@ function RecaptchaV2Component(
function RecaptchaV3Component( function RecaptchaV3Component(
props: { props: {
children: any; children: any;
onClick?: (event: React.MouseEvent<HTMLElement>) => void; isDisabled?: boolean;
recaptchaType?: RecaptchaType; recaptchaType?: RecaptchaType;
handleError: (event: React.MouseEvent<HTMLElement>, error: string) => void; handleError: (event: React.MouseEvent<HTMLElement>, error: string) => void;
} & RecaptchaProps, } & RecaptchaProps,
@ -363,6 +364,7 @@ function RecaptchaV3Component(
}; };
const handleBtnClick = (event: React.MouseEvent<HTMLElement>) => { const handleBtnClick = (event: React.MouseEvent<HTMLElement>) => {
if (props.isDisabled) return;
if (status === ScriptStatus.READY) { if (status === ScriptStatus.READY) {
(window as any).grecaptcha.ready(() => { (window as any).grecaptcha.ready(() => {
try { try {
@ -405,6 +407,7 @@ function RecaptchaV3Component(
function BtnWrapper( function BtnWrapper(
props: { props: {
children: any; children: any;
isDisabled?: boolean;
onClick?: (event: React.MouseEvent<HTMLElement>) => void; onClick?: (event: React.MouseEvent<HTMLElement>) => void;
} & RecaptchaProps, } & RecaptchaProps,
) { ) {
@ -436,6 +439,7 @@ function ButtonComponent(props: ButtonComponentProps & RecaptchaProps) {
clickWithRecaptcha={props.clickWithRecaptcha} clickWithRecaptcha={props.clickWithRecaptcha}
googleRecaptchaKey={props.googleRecaptchaKey} googleRecaptchaKey={props.googleRecaptchaKey}
handleRecaptchaV2Loading={props.handleRecaptchaV2Loading} handleRecaptchaV2Loading={props.handleRecaptchaV2Loading}
isDisabled={props.isDisabled}
onClick={props.onClick} onClick={props.onClick}
recaptchaType={props.recaptchaType} recaptchaType={props.recaptchaType}
> >

View File

@ -223,7 +223,7 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
borderRadius: cellProperties.borderRadius, borderRadius: cellProperties.borderRadius,
boxShadow: cellProperties.boxShadow, boxShadow: cellProperties.boxShadow,
boxShadowColor: cellProperties.boxShadowColor, boxShadowColor: cellProperties.boxShadowColor,
iconName: cellProperties.iconName, iconName: cellProperties.iconName || "add",
iconAlign: cellProperties.iconAlign, iconAlign: cellProperties.iconAlign,
isCellVisible: cellProperties.isCellVisible ?? true, isCellVisible: cellProperties.isCellVisible ?? true,
label: cellProperties.menuButtonLabel ?? "Open menu", label: cellProperties.menuButtonLabel ?? "Open menu",