GravityKit/GravityView

Edit Entry: Change the action of the Cancel button to close the lightbox

rafaehlers opened this issue · 4 comments

When opening the Edit Entry layout inside a lightbox, the "Close" button redirects the user to the single entry layout, which, in some cases, is not the desired behavior.

We should either add a new setting inside the View Settings > Edit Entry tab to toggle this behavior or change it automatically: if the edit entry layout was opened inside a lightbox, change the Cancel button action to close the lightbox. If not, please leave it as it is right now: redirecting to the Single Entry page.

Workaround:

function custom_cancel_onclick_js( $back_link, $form, $entry, $view_id, $update_count ) {
	$run_on_views = [2334]; //Change this to the IDs of the Views you'd like to run this filter [100,200,300,...]
	if( in_array( $view_id, $run_on_views ) ){
		return 'window.parent.postMessage({closeFancybox: true}, "*"); return false;';
	}
}
add_filter( 'gravityview/edit_entry/cancel_onclick', 'custom_cancel_onclick_js', 100, 5 );

@Mwalek or @rafaehlers, could you please test b70fcf7 on develop?

@mrcasual works perfectly! However, I think some clarification might be helpful for users to know that the new setting only applies to the cancel link inside a lightbox.

Instead of calling the setting "Cancel Link Action," we could perhaps call it "Lightbox Cancel Link Action" or "Cancel Link Action (Inside Lightbox)" to highlight that this setting applies specifically within a lightbox.

Alternatively, we could add a tooltip that says; "This setting controls the action taken by the cancel link inside the lightbox." or something like that.

Released in GV 2.31