ui: Confirmation on exit from exec as long as socket has been opened #19985
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #19849
In an exec window context, navigating away from the page is not possible by in-page links, as there are none (besides Documentation, which opens in a new tab). Otherwise, closing the window by clicking exit, or using a keyboard shortcut like ctrl+w, ctrl+q, etc. is the most common method.
Unfortunately, some of those keyboard shortcuts are also used for in-terminal activity (like
ctrl+w
to delete a word in bash, or split a terminal in vim), and users' muscle memory may cause them to close a window, losing time and context along the way.This PR adds a beforeunload handler to the exec terminal component, triggered whenever a socket is open and the user does an action that would close the parent tab/window. It will add a prompt asking the user if they meant to close it, and if they hit cancel or escape, it will bring their context back to the cursor in the terminal. Otherwise, the window will be closed.