Contextual save bar broken

This has broken multiple times now, and i’ve posted this in an existing thread but it’s not getting any attention so i’m going to post again.

When you click save on the contextual save bar, on Chrome, you get presented with this popup, as we’re forced to use it, can this be fixed as it’s causing confusion amongst merchants.

I would advise posting some reproduction steps including some code examples to get any help with figuring this out.

I’m using the save bar API Save Bar API

here is the sample code to reproduce

once the save bar is shown programmatically, clicking save will bring up the popup in chrome. This issue was fixed some weeks ago, then regressed soon after.

<!DOCTYPE HTML>
<html>
<head>
	<title>test</title>
	<meta name="shopify-api-key" content="REMOVED" />
	<script src="https://cdn.shopify.com/shopifycloud/app-bridge.js"></script>
	<script src="https://cdn.shopify.com/shopifycloud/polaris.js"></script>
</head>
<body>
	<s-page>
		<form id='frmSettings' method='post' action='?action=save' >
			<input type='text' name='data' value='' />
		</form>

		<ui-save-bar id="my_save_bar">
			<button id="my_save_bar_save" variant="primary" onClick="doFormSubmit()"></button>
			<button id="my_save_bar_reset" onClick="doFormReset()"></button>
		</ui-save-bar>
	</s-page>
	<script type="text/javascript">
		shopify.saveBar.show('my_save_bar');
	
		function doFormReset() {
			
		}

		function doFormSubmit() {
			document.getElementById('frmSettings').submit();
		}
	</script>
</body>
</html>

Hey @Min_Liu :waving_hand: thanks for sharing the reproduction.

I’ve confirmed the Chrome leave-site dialog using your sample in a clean app, and I’m digging into this further. I’ll follow up here when I have more to share.

Hey @Min_Liu - following up here.

We just shipped a fix and it’s live now, so you should no longer see the popup on save. Let me know if this cleared things up for you!

Thanks Wes, looks good now.

This has occurred a few things now, is it due to recursion or chrome updates? it will be good if it didn’t creep up again in future!

Hey @Min_Liu - this was an App Bridge regression, not recursion or a Chrome update. The earlier fix relied on a short timer, and browser event timing could cause the “Leave site?” prompt to return.

The new fix removes that timing race, and we’ve added regression coverage for this save flow. While I can’t promise a similar issue could never occur again, this specific cause is now covered.

Hope this helps!