It looks like there is a bug in Shopify Polaris Web Components →
The repoducible code would be -
<s-page heading="Test app">
<s-button variant="primary" slot="primary-action" onClick={() => {console.log(‘button clicked‘)}}>
Enable Auto-Sorting !!!
</s-button>
</s-page>
The issue is that the onClick handler is not working if you navigate between pages.
I’ve added the demo below.
Does anyone else have this issue?
I know a workround (remove the variant="primary" from button) but this is not aligned with the docs. So it seems like a bug.