useCurrencyFormatter.ts
2 years ago
useDonationSummary.ts
1 year ago
useFormData.ts
11 months ago
useFormSubmitButton.ts
1 year ago
useVisibilityCondition.ts
4 months ago
useFormSubmitButton.ts
22 lines
| 1 | /** |
| 2 | * @since 4.1.1 updated the selector to use the next button classname |
| 3 | * @since 4.0.0 |
| 4 | */ |
| 5 | export default function useFormSubmitButton(): HTMLButtonElement | null { |
| 6 | const donationFormWithSubmitButton = Array.from(document.forms).pop(); |
| 7 | |
| 8 | const submitButton: HTMLButtonElement = donationFormWithSubmitButton?.querySelector('[type="submit"]'); |
| 9 | if (submitButton) { |
| 10 | return submitButton; |
| 11 | } |
| 12 | |
| 13 | const nextButton: HTMLButtonElement = donationFormWithSubmitButton?.querySelector( |
| 14 | '.givewp-donation-form__steps-button-next[type="button"]' |
| 15 | ); |
| 16 | if (nextButton) { |
| 17 | return nextButton; |
| 18 | } |
| 19 | |
| 20 | return null; |
| 21 | } |
| 22 |