Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webui: Prevent the Anaconda window from being closed by keyboard shortcuts #4948

Merged

Conversation

adamkankovsky
Copy link
Contributor

The changes in this PR do not prevent closing the application window, but only add a confirmation window before quitting.
In most browsers this behavior is prevented because it could be used to attack https://stackoverflow.com/questions/30781070/prevent-onbeforeunload-to-close-page-in-any-case.
Therefore, this seems to me to be the only possible solution at the moment.

@adamkankovsky adamkankovsky force-pushed the webui-prevent-window-to-be-closed branch 2 times, most recently from 479615b to 29dfb98 Compare July 26, 2023 08:14
Copy link
Contributor

@VladimirSlavik VladimirSlavik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Note that you probably want ack from a "full webui dev" too...

Copy link
Contributor

@KKoukiou KKoukiou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives the default dialog from firefox.

screenshot-2023-07-26-14:51:36

@garrett can we keep this or we need a custom dialog?

Also @adamkankovsky can we please have a test for this?

@garrett
Copy link

garrett commented Jul 27, 2023

@garrett can we keep this or we need a custom dialog?

Unfortunately, I think we're stuck with this.

You used to be able to customize it, but all browsers removed support for this a few years ago: https://stackoverflow.com/questions/38879742/is-it-possible-to-display-a-custom-message-in-the-beforeunload-popup

The changes in this PR do not prevent closing the application window, but only add a confirmation window before quitting.

We want it specifically for closing the application window, including Ctrl-W, Ctrl-Q, and the (X) icon in the top-right. Bummer.

We do not want this prompt when quitting from the UI. That can and should be handled in-page with a PatternFly modal.

So does that mean this PR doesn't do what we want it to?

@garrett
Copy link

garrett commented Jul 27, 2023

There are apparently a bunch of custom settings one can toggle in Firefox to adjust prompting on closing: https://www.reddit.com/r/firefox/comments/si9in4/comment/hv8hd7v/?context=3 — I can add some of these to the Firefox theme's user.js. I wonder if any of those would do what we want. (Time to experiment...)

@garrett
Copy link

garrett commented Jul 27, 2023

@KKoukiou What did you do to get this dialog?

@KKoukiou
Copy link
Contributor

KKoukiou commented Jul 27, 2023

@KKoukiou What did you do to get this dialog?

Ctrl + w. I just tested on the remote accessed browser window.

@garrett
Copy link

garrett commented Jul 27, 2023

I tried closing a Firefox window with just one tab... Penpot... and got this modal:

image

So this should theoretically work for Anaconda too, for the (X) icon.

(This is Firefox; I'm just using a custom theme that makes it look more like GNOME.)

@adamkankovsky
Copy link
Contributor Author

@garrett Thanks to the fact that it is done via window.onbeforeunload which captures all window closures from the user side. I've tried it and even on the x button it works.

@garrett
Copy link

garrett commented Jul 27, 2023

captures all window closures from the user side. I've tried it and even on the x button it works.

🎉 Excellent to hear!

@adamkankovsky adamkankovsky force-pushed the webui-prevent-window-to-be-closed branch from 253184a to 901f4a4 Compare July 27, 2023 14:12
@KKoukiou KKoukiou added the blocked Don't merge this pull request! label Jul 28, 2023
@KKoukiou KKoukiou force-pushed the webui-prevent-window-to-be-closed branch from 901f4a4 to c069fb9 Compare July 28, 2023 15:28
@garrett
Copy link

garrett commented Aug 7, 2023

Hi. Any reason this hasn't been merged yet? If there's anything that needs to be done still, can we merge this and split whatever it might be out to a follow-up? Thanks!

@KKoukiou
Copy link
Contributor

KKoukiou commented Aug 7, 2023

Hi. Any reason this hasn't been merged yet? If there's anything that needs to be done still, can we merge this and split whatever it might be out to a follow-up? Thanks!

so I havent managed to get in the required test changes cockpit-project/cockpit#19148

You can remove the tests - merge it and create a new PR - mark it as blocked on my cockpit PR

@adamkankovsky adamkankovsky force-pushed the webui-prevent-window-to-be-closed branch from c069fb9 to 797963e Compare August 7, 2023 16:03
@adamkankovsky adamkankovsky removed the blocked Don't merge this pull request! label Aug 8, 2023
@adamkankovsky adamkankovsky force-pushed the webui-prevent-window-to-be-closed branch from 797963e to 803a982 Compare August 8, 2023 07:20
@adamkankovsky adamkankovsky force-pushed the webui-prevent-window-to-be-closed branch from 803a982 to bdc0d85 Compare August 8, 2023 13:50
Copy link
Contributor

@KKoukiou KKoukiou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need to be squashed

…tcuts

This commit also removes the b.reload check on the language test, as now
reloading the browser will be guarded with a prompt, and we currently
dont have a way to reply to that. [1]

[1] cockpit-project/cockpit#19148
@KKoukiou KKoukiou force-pushed the webui-prevent-window-to-be-closed branch from 5e8a31d to e1ec43f Compare August 8, 2023 17:39
@KKoukiou
Copy link
Contributor

KKoukiou commented Aug 8, 2023

/kickstart-test --waive webui-only

@KKoukiou KKoukiou merged commit 20b2e89 into rhinstaller:master Aug 8, 2023
13 of 14 checks passed
@adamkankovsky adamkankovsky deleted the webui-prevent-window-to-be-closed branch August 9, 2023 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants