gabrielmaldi / chrome-lock-tab

Chrome extension to prevent a tab from being closed accidentally
https://chrome.google.com/webstore/detail/lock-tab/nhbdiieigbgalknjplfpgmjnpbnkchnb
14 stars 1 forks source link

Tab get unlocked without asking #6

Open krab-skunk opened 8 months ago

krab-skunk commented 8 months ago

Hi ;)

Im using latest version 1.2.1 of Lock Tab on Version 1.60.118 Chromium: 119.0.6045.163 (Official Build) (arm64) and i notice that for example, i lock a github page, and i go to create a release, when submitting the form and clicking create , i have a popup asking me if i want to leave the site as changed may not have been saved

First of all , I don't understand why its telling me this since creating a release is not sending me to another website, and since i want to create this release, i have to click leave this site, and consequently the Tab get unlocked :(

I would find this plugin very useful, but this bug prevent me from using it.

worth mentionning, its not only on release page and it doesn't occur every time, it generally occur when trying to submit a form

Thanks for your help :)

gabrielmaldi commented 8 months ago

Hi, @krab-skunk. First of all thank you for using Lock Tab! And for the detailed explanation.

I understand your use case and would love to be able to cover it. Unfortunately, I don't think it's possible 😞. Currently, the extension uses the beforeunload event to intercept (and prevent) navigating away or refreshing. This is the only way I have found that allows for telling the browser to prevent that action and stay on the same page. This event fires every time the current page is going to be unloaded and that includes submitting a form, navigating to another page on the same site or to another site; and there's no way for the extension to know, at this point, what that action will be or the target URL of the upcoming navigation.

The extension could, theoretically, "attach itself" to the submit event of every form's submit button, and when an unload event occurs immediately after a form submit, treat is a noop. But this would require meddling with pages and even then there would be many corner cases; I'd very much rather keep the extension simple 😊.

I'll keep this ticket open so if anyone comes up with an idea of how to implement this in a clean way, I'll gladly look into it.

Thanks!