@@ -440,20 +440,33 @@ class App {
440440 modalButton . addEventListener (
441441 'click' ,
442442 ( ) => {
443- // check if this is a POST action (like DELETE with formaction) or GET (link href )
443+ // Case 1: POST action with formaction (like DELETE with CSRF token )
444444 const formAction = actionElement . getAttribute ( 'formaction' ) ;
445-
446445 if ( formAction ) {
447- // POST action: use the hidden form with CSRF token (like DELETE)
448446 const form = document . querySelector ( '#action-confirmation-form' ) ;
449447 form . setAttribute ( 'action' , formAction ) ;
450448 form . submit ( ) ;
451- } else {
452- // GET action: navigate to the href URL
453- const href = actionElement . getAttribute ( 'href' ) ;
454- if ( href ) {
455- window . location . href = href ;
456- }
449+ return ;
450+ }
451+
452+ // Case 2: dropdown action rendered as form (data-ea-action-form-id)
453+ const actionFormId = actionElement . getAttribute ( 'data-ea-action-form-id' ) ;
454+ if ( actionFormId ) {
455+ document . getElementById ( actionFormId ) . submit ( ) ;
456+ return ;
457+ }
458+
459+ // Case 3: standalone button inside a <form> (renderAsForm)
460+ const parentForm = actionElement . closest ( 'form' ) ;
461+ if ( parentForm && parentForm . hasAttribute ( 'action' ) ) {
462+ parentForm . submit ( ) ;
463+ return ;
464+ }
465+
466+ // Case 4: GET action with href
467+ const href = actionElement . getAttribute ( 'href' ) ;
468+ if ( href ) {
469+ window . location . href = href ;
457470 }
458471 } ,
459472 { once : true }
@@ -609,17 +622,25 @@ class App {
609622
610623 #createActionHandlers( ) {
611624 // handle form submissions via data attribute (replaces inline onclick handlers)
625+ // skip elements with confirmation modals (handled by #createActionConfirmationModals)
612626 document . querySelectorAll ( '[data-ea-action-form-id]' ) . forEach ( ( element ) => {
613627 element . addEventListener ( 'click' , ( event ) => {
628+ if ( element . hasAttribute ( 'data-action-confirmation' ) ) {
629+ return ;
630+ }
614631 event . preventDefault ( ) ;
615632 const formId = element . getAttribute ( 'data-ea-action-form-id' ) ;
616633 document . getElementById ( formId ) . submit ( ) ;
617634 } ) ;
618635 } ) ;
619636
620637 // handle navigation via data attribute (replaces inline onclick handlers)
638+ // skip elements with confirmation modals (handled by #createActionConfirmationModals)
621639 document . querySelectorAll ( '[data-ea-action-url]' ) . forEach ( ( element ) => {
622640 element . addEventListener ( 'click' , ( event ) => {
641+ if ( element . hasAttribute ( 'data-action-confirmation' ) ) {
642+ return ;
643+ }
623644 event . preventDefault ( ) ;
624645 window . location = element . getAttribute ( 'data-ea-action-url' ) ;
625646 } ) ;
0 commit comments