Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/build/frontend/multi.step.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '9457afa85f7e33a36e73');
<?php return array('dependencies' => array(), 'version' => '45709365defdf608dab0');
2 changes: 1 addition & 1 deletion assets/build/frontend/multi.step.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions assets/src/frontend/multi.step/PageState.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ PageState.prototype.changePage = async function ( isBack ) {
return;
}

if ( this.isLast() ) {
return;
}

if ( this.getLockState().current ) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '37cff6ecfd5e3812f98c');
<?php return array('dependencies' => array(), 'version' => '3d37e5f797b261c2ae1f');
2 changes: 1 addition & 1 deletion modules/switch-page-on-change/assets/build/frontend.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 35 additions & 19 deletions modules/switch-page-on-change/assets/src/frontend/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,42 @@ addAction(
* @param page {PageState}
*/
function ( page ) {
// Handle click events for radio inputs to allow re-selection
const getSwitchWrapper = ( node ) => node?.closest(
'.jet-fb-switch-page-on-change',
);

const changePage = () => page.changePage( false )
.then( () => {} )
.catch( () => {} );

// Handle click events for enabled radio inputs to allow re-selection.
page.node.addEventListener( 'click', ( event ) => {
// Check if this is a radio input
if ( event.target.type === 'radio' ) {
// Check if there's a check-mark-control in the same wrapper
const wrapper = event.target.closest( '.jet-form-builder__field-wrap' );
if ( wrapper && wrapper.querySelector( '.check-mark-control' ) ) {
if ( event.target.checked ) {
page.changePage( false ).then( () => {} ).catch( () => {} );
}
} else {
// For regular radio inputs without check-mark, also handle clicks
// Small delay to ensure the value is updated
setTimeout( () => {
if ( event.target.checked ) {
page.changePage( false ).then( () => {} ).catch( () => {} );
}
}, 10 );
if ( event.target.type !== 'radio' ) {
return;
}

const switchWrapper = getSwitchWrapper( event.target );

if ( !switchWrapper || !page.isNodeBelongThis( switchWrapper ) ) {
return;
}

const wrapper = event.target.closest( '.jet-form-builder__field-wrap' );
if ( wrapper?.querySelector( '.check-mark-control' ) ) {
if ( event.target.checked ) {
changePage();
}

return;
}

// For regular radio inputs without check-mark, allow click-driven
// transitions after the checked state has updated.
setTimeout( () => {
if ( event.target.checked ) {
changePage();
}
}, 10 );
} );

const wrappers = page.node.querySelectorAll(
Expand All @@ -53,8 +69,8 @@ addAction(
if ( isEmpty( node.jfbSync.getValue() ) ) {
return;
}
page.changePage( false ).then( () => {} ).catch( () => {} );
changePage();
} );
}
},
);
);
Loading