Skip to content
Open
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
18 changes: 17 additions & 1 deletion polaris-react/src/components/ResourceItem/ResourceItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,26 @@ class BaseResourceItem extends Component<CombinedProps, State> {
}

if (url && anchor) {
anchor.click();
// PREVENT default navigation
event.preventDefault();
// Check savebar BEFORE navigating
this.handleNavigationWithSaveBarCheck(anchor);
}
};

private async handleNavigationWithSaveBarCheck(anchor: HTMLAnchorElement) {
try {
// Check if shopify saveBar is available and has active unsaved changes
if (typeof window !== 'undefined' && (window as any).shopify?.saveBar) {
await (window as any).shopify.saveBar.leaveConfirmation();
}
// Only navigate if confirmation succeeds
window.location.href = anchor.href;
} catch (error) {
// User cancelled - don't navigate
}
}

// This fires onClick when there is a URL on the item
private handleKeyUp = (event: React.KeyboardEvent<HTMLElement>) => {
const {
Expand Down