|
164 | 164 | </form>
|
165 | 165 | <div
|
166 | 166 | id="newsletter-toast"
|
167 |
| - class="tw-fixed tw-bottom-5 tw-right-2 tw-transform tw-bg-[#7782FF] tw-text-white tw-p-6 tw-rounded-lg tw-shadow-lg tw-z-50 tw-hidden tw-transition-opacity tw-duration-300" |
| 167 | + class="tw-fixed tw-bottom-5 tw-right-2 tw-transform tw-bg-[#7782FF] tw-text-white tw-p-6 tw-rounded-lg tw-shadow-lg tw-z-50 tw-hidden tw-transition-opacity tw-duration-300 tw-text-base" |
168 | 168 | ></div>
|
169 | 169 | </div>
|
170 | 170 |
|
|
284 | 284 | ) {
|
285 | 285 | recaptchaToken = token;
|
286 | 286 |
|
287 |
| - // Hide loader, show success state briefly |
288 |
| - const loader = document.getElementById("newsletter-captcha-loader"); |
289 |
| - if (loader) { |
290 |
| - loader.style.display = "flex"; |
291 |
| - } |
| 287 | + // // Hide loader immediately on success |
| 288 | + // const loader = document.getElementById("newsletter-captcha-loader"); |
| 289 | + // if (loader) { |
| 290 | + // loader.style.display = "none"; |
| 291 | + // } |
292 | 292 |
|
293 | 293 | // Auto-submit after reCAPTCHA completion (like Vue component)
|
294 | 294 | setTimeout(async () => {
|
|
307 | 307 | );
|
308 | 308 | if (!recaptchaContainer) return;
|
309 | 309 |
|
310 |
| - // If widget already exists, don't create another one |
311 |
| - if (recaptchaWidgetId !== null) return; |
| 310 | + // Clear any existing widget content first |
| 311 | + recaptchaContainer.innerHTML = ""; |
312 | 312 |
|
313 | 313 | try {
|
314 | 314 | recaptchaWidgetId = window.grecaptcha.render(recaptchaContainer, {
|
|
317 | 317 | "expired-callback": window.onRecaptchaExpired,
|
318 | 318 | theme: "dark",
|
319 | 319 | });
|
320 |
| - } catch (error) {} |
| 320 | + } catch (error) { |
| 321 | + // If render fails, reset the widget ID |
| 322 | + recaptchaWidgetId = null; |
| 323 | + } |
321 | 324 | }
|
322 | 325 |
|
323 | 326 | // Submit form function (like Vue component)
|
|
334 | 337 | container.classList.add("tw-flex");
|
335 | 338 | }
|
336 | 339 |
|
337 |
| - // Hide loader when showing reCAPTCHA |
| 340 | + // Ensure loader is hidden when showing reCAPTCHA |
338 | 341 | if (loader) {
|
339 | 342 | loader.style.display = "none";
|
340 | 343 | }
|
341 | 344 |
|
342 |
| - // Wait for DOM update, then render reCAPTCHA |
| 345 | + // Always try to initialize reCAPTCHA, even if widget exists |
343 | 346 | setTimeout(() => {
|
344 |
| - if ( |
345 |
| - recaptchaDiv && |
346 |
| - window.grecaptcha && |
347 |
| - recaptchaWidgetId === null |
348 |
| - ) { |
| 347 | + if (recaptchaDiv && window.grecaptcha) { |
| 348 | + // Destroy existing widget if it exists |
| 349 | + if (recaptchaWidgetId !== null) { |
| 350 | + try { |
| 351 | + window.grecaptcha.reset(recaptchaWidgetId); |
| 352 | + } catch (error) { |
| 353 | + // If reset fails, clear the container |
| 354 | + recaptchaDiv.innerHTML = ""; |
| 355 | + } |
| 356 | + recaptchaWidgetId = null; |
| 357 | + } |
| 358 | + // Always create a new widget |
349 | 359 | initializeRecaptcha();
|
350 | 360 | }
|
351 | 361 | }, 100);
|
|
370 | 380 | return;
|
371 | 381 | }
|
372 | 382 |
|
| 383 | + // Hide loader during processing |
| 384 | + const loader = document.getElementById("newsletter-captcha-loader"); |
| 385 | + if (loader) { |
| 386 | + loader.style.display = "none"; |
| 387 | + } |
| 388 | + |
373 | 389 | try {
|
374 | 390 | isSubmitting = true;
|
375 | 391 |
|
|
420 | 436 | if (window.grecaptcha && recaptchaWidgetId !== null) {
|
421 | 437 | try {
|
422 | 438 | window.grecaptcha.reset(recaptchaWidgetId);
|
423 |
| - // Clear the container completely |
424 |
| - const recaptchaDiv = document.getElementById( |
425 |
| - "newsletter-recaptcha" |
426 |
| - ); |
427 |
| - if (recaptchaDiv) { |
428 |
| - recaptchaDiv.innerHTML = ""; |
429 |
| - } |
430 |
| - recaptchaWidgetId = null; |
431 |
| - } catch (error) {} |
| 439 | + } catch (error) { |
| 440 | + // Silent error handling |
| 441 | + } |
| 442 | + } |
| 443 | + |
| 444 | + // Clear the container and reset widget ID |
| 445 | + const recaptchaDiv = document.getElementById( |
| 446 | + "newsletter-recaptcha" |
| 447 | + ); |
| 448 | + if (recaptchaDiv) { |
| 449 | + recaptchaDiv.innerHTML = ""; |
432 | 450 | }
|
| 451 | + recaptchaWidgetId = null; |
433 | 452 | recaptchaToken = "";
|
434 | 453 |
|
435 | 454 | // Analytics tracking
|
|
472 | 491 | if (window.grecaptcha && recaptchaWidgetId !== null) {
|
473 | 492 | try {
|
474 | 493 | window.grecaptcha.reset(recaptchaWidgetId);
|
475 |
| - // Clear the container completely |
476 |
| - const recaptchaDiv = document.getElementById( |
477 |
| - "newsletter-recaptcha" |
478 |
| - ); |
479 |
| - if (recaptchaDiv) { |
480 |
| - recaptchaDiv.innerHTML = ""; |
481 |
| - } |
482 |
| - recaptchaWidgetId = null; |
483 |
| - } catch (error) {} |
| 494 | + } catch (error) { |
| 495 | + // Silent error handling |
| 496 | + } |
| 497 | + } |
| 498 | + |
| 499 | + // Clear the container and reset widget ID |
| 500 | + const recaptchaDiv = document.getElementById( |
| 501 | + "newsletter-recaptcha" |
| 502 | + ); |
| 503 | + if (recaptchaDiv) { |
| 504 | + recaptchaDiv.innerHTML = ""; |
484 | 505 | }
|
| 506 | + recaptchaWidgetId = null; |
485 | 507 | recaptchaToken = "";
|
486 | 508 |
|
487 | 509 | // GTM error tracking
|
|
817 | 839 | id="feedback-tab-other"
|
818 | 840 | role="tab"
|
819 | 841 | aria-selected="false"
|
820 |
| - data-type="Other" |
| 842 | + data-type="Feedback" |
821 | 843 | class="feedback-tab tw-flex tw-items-center tw-gap-2 tw-py-1.5 tw-rounded-md tw-text-xs tw-font-medium tw-transition-all tw-flex-1 tw-justify-center tw-cursor-pointer tw-border tw-border-gray-400 tw-text-gray-600 hover:tw-text-gray-900 hover:tw-bg-gray-100 hover:tw-border-gray-200"
|
822 | 844 | style="border: 1px solid gray !important"
|
823 | 845 | >
|
|
0 commit comments