File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 11import { enableUnlimitedInputs } from './unlimitedInput' ;
22import { updateAdvancedTextarea } from './toggleAdvanced' ;
3- import { showSpinner } from './helpers' ;
3+ import { isDesktopSafari , showSpinner } from './helpers' ;
44
55export default function handleFormSubmit ( ) {
66 const mainForm = document . querySelector ( '#main-form' ) ;
77 if ( mainForm ) {
8- mainForm . addEventListener ( 'submit' , ( ) => {
8+ mainForm . addEventListener ( 'submit' , ( event ) => {
99 // Show loading spinner
1010 showSpinner ( ) ;
1111
12+ // Wait a bit if Desktop Safari to ensure spinner is shown
13+ if ( isDesktopSafari ( ) ) {
14+ const submitButton = document . querySelector ( 'button[type="submit"]' ) ;
15+ if ( ! submitButton . dataset . clicked ) {
16+ event . preventDefault ( ) ;
17+ submitButton . dataset . clicked = 'true' ;
18+ setTimeout ( ( ) => {
19+ mainForm . submit ( ) ;
20+ } , 500 ) ;
21+ }
22+ }
23+
1224 // Enable any disabled inputs to ensure all fields are submitted
1325 if ( mainForm . classList . contains ( 'js-enable-inputs-on-submit' ) ) {
1426 document . querySelectorAll ( 'input[disabled]' ) . forEach ( ( input ) => {
Original file line number Diff line number Diff line change @@ -43,6 +43,14 @@ export function parseAndSortIpLists(ipListsData) {
4343 return ipLists . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ;
4444}
4545
46+ // Determines if the current browser is Desktop Safari
47+ export function isDesktopSafari ( ) {
48+ const userAgent = window . navigator . userAgent ;
49+ const isSafari = / ^ ( (? ! c h r o m e | a n d r o i d ) .) * s a f a r i / i. test ( userAgent ) ;
50+ const isMobile = / i P h o n e | i P a d | i P o d | A n d r o i d / i. test ( userAgent ) ;
51+ return isSafari && ! isMobile ;
52+ }
53+
4654// Posts data to the given URL and returns the response
4755export async function post ( url , data , headers = { } ) {
4856 const requestOptions = {
You can’t perform that action at this time.
0 commit comments