Custom Website Service breaks JS click events on <a> tags
Preflight Checklist
- [x] I agree to follow the Code of Conduct that Ferdium Recipes adheres to.
- [x] I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Ferdium Version
7.0.0
Recipe Name
Custom Website
Recipe Version
1.5.1
Last Known working version of the recipe
No response
Steps to reproduce
- Add a Service - Custom Website - https://phanpy.social
- Log in using any Mastodon account
- Click a profile picture or username in the feed
Expected Behavior
When installing https://phanpy.social as a Custom Website, clicking on a profile opens the profile overlay drawer like in a browser
Actual Behavior
Nothing happens in Ferdium and the profile URL is opened in an external browser
Screenshots
No response
Additional Information
This likely affects other services/websites and is due to the way franz-custom-website's webview.js is implemented. When an HTML <a> element is clicked, ferdium will open the URL in its href attribute even if the website has installed a click event handler that overrides browser behaviour to trigger in-page navigation or some other action.
This is compounded by the fact that the trapLinkClicks ("Open URLs within Ferdium") setting does not fully deactivate Ferdium's meddling with click events:
https://github.com/ferdium/ferdium-recipes/blob/main/recipes/franz-custom-website/webview.js#L27
instead of explicitly replicating default behaviour by changing window.location, when trapLinkClicks is true, ferdium should not call event.preventDefault() or event.stopPropagation(), or simply not install the click handler at all.
As mentioned in the PR linked to this issue, this seems to be specific to a given website, and the way forward would likely be to modify only the recipe for which you want that to happen, unless you find a way to globally find when an event is going to trigger an exit from the app.
If you don't necessarily want that modification to become a full recipe in Ferdium, you can also make a local one by copying the files of the normal recipe into Ferdium's config folder (in recipes/dev, cf the tab Custom Services in the window to add a new service) and then modify the webview file there, which will then be specific for that recipe instead of applying to all the services that are using the Custom Website recipe.
Let me know if that seems good for you.