16

Is there a specific reason why browsers don't inquire whether users want to close a tab or not? This feature is enabled in some browsers (possibly all, though not certain), but only for multiple tabs, and users must permit this, with varying levels of difficulty. For instance, enabling this feature is relatively simple in Firefox but almost impossible in Chrome unless one does a search on how to enable it. However, this still applies solely to multiple tabs and only when shutting down the browser. If a user opts to close several tabs at once without closing the browser (for example, by choosing "close all tabs to the right"), there won't be a warning either.

This approach seems to be in clear violation of recognized UI rules and commonly accepted UI heuristics (including Shneiderman's laws 5, 6, and 7; Nielsen's 5 and 9; ISO 9241/110 rules 3 and 5).

So I wonder if there's a specific reason (whether technological, performance-related, usability-based, etc.) for which all browsers prevent user's locus of control.

In my opinion, and according to all accepted heuristics, this should be a feature. In any case, an optional one, but it should be present, so it's weird to find out it doesn't even exist as a possibility.

EDIT:

Very nice and interesting answers so far, but they seem to skirt around two particular facts: the potential for information recovery and the annoyance of accidental tab closure. Regarding the annoyance, I agree that it's frustrating, which is why I emphasized that any solution should be optional.

As for the possibility of recovering information, this isn't always the case. To begin with, many apps are poorly coded, making recovery difficult or impossible. But let me illustrate with a real-life experience that prompted me to ask this question.

I had a lengthy process running in one tab, which didn't focus. The only requirement was not to close the window while it was running. I continued working on something else in another tab, and when I tried to return to the initial tab, I accidentally closed it (a situation similar to what Angel mentioned).

In my case, it was a Psycho-Py experiment, but my curiosity led me to test other occurrences that weren't forms, but running processes: a WordPress backup using the All in One Security plugin, a WordPress batch image conversion plugin, and a PHP upgrade on a server. I repeated the process by closing the tab with the running process while in another tab. All of these instances allowed me to close the tab without warning, resulting in complete loss, with no possibility of recovery. In one extreme case, I even had to restart the server.

I believe browsers should offer an option to ask for confirmation when closing a tab with an ongoing process, allowing users to activate or deactivate this feature as needed. Users should ALWAYS have complete control. For instance, when I close my Mac, it prompts me to confirm what to do with any important open app that is running. It ignores some apps (such as Spotify or Netflix) but doesn't ignore others (like Firefox or Time controlled tasks like Togglr) if there's a process running or an unsaved form. This selective approach puts control where it should be - in the hands of the user.

11
  • 7
    A tab is only closed when a user asks for it - can you elaborate on why you think this is removing control? Aug 17, 2023 at 12:36
  • 19
    "Users" (ie non-technical people) generally don't read dialogs (anecdotal, but happens enough over the years to make it a general rule). If you then prompt them every time they click close, they will always assume it's a "do you want to close" dialog - so the one time it's a "if you close this you'll lose all your work" dialog, it will just be another dialog that they have to close, and will close it automatically without reading it. Better to have user interruption as an exception rather than the norm.
    – fdomn-m
    Aug 17, 2023 at 12:38
  • 19
    Quite frankly, pick your poison. Pop-up fatigue is a very real thing. Besides Ctrl + Shift + t, or "reopen recently closed tab" for the shortcut-challenged, exists for a reason; albeit I think its discoverability should be heightened, especially in mobile. Closing a tab without confirmation is a far lesser evil than propagating pop-up fatigue.
    – MonkeyZeus
    Aug 17, 2023 at 13:52
  • 14
    I would argue that your example showcases not one but two problems with that application, not a problem with the browser. That app should be using a proper onbeforeunload event handler to prompt the user for confirmation if they try to close the tab when something is running, and the backend should be designed in such a way that it can recover from the situation where the tab is gone (no matter the reason, systems crash, and that should not kill things like this). Aug 17, 2023 at 17:00
  • 2
    This feature exist. Your apps/websites are just not using them. Instead of asking the browser to change its default behavior for a feature that is already implemented but not default you should ask Wordpress/Psycho-py to confirm window close
    – slebetman
    Aug 18, 2023 at 14:31

7 Answers 7

9

Pinned tabs

The major browser vendors have chosen to address the problem of unintended tab closure by offering the "pin tab" feature:

Pinned Tabs don't have a close button so you can't accidentally close them.

As well as removing the header text, pinning a tab also removes the "x" button, meaning you cannot click this button to remove it.

Close a pinned tab

In the Safari app on your Mac, Control-click a pin, then choose Close Tab.

When a tab is pinned to the browser, the close icon doesn’t show up for that tab. That means you cannot easily close a pinned tab.

Of course, this requires that the user proactively protect a tab that contains valuable data. Furthermore, it requires that a user know what "pinning" a tab means (I didn't an hour ago!). Pinning tabs also makes them take up less space, which may or may not be a good thing depending on the intended usage.

I'd opine there is room for improvement in how this feature is typically implemented, although now that I know about it, I personally think I prefer pinning to a warning on closure, since for my workflow, in the vast majority of cases, closing a tab does not lose valuable data.

Lack of demand for a warning

As a crude measure of users' interest, I did a couple searches in the Firefox Bugzilla, Tabbed Browser component:

  • "warn clos" (deliberately finding both "close" and "closing") only finds 12 bugs, all of which are in the context of multiple and/or pinned tabs

  • "pinned tab" returns 84 results

From this I conclude that users implicitly have expressed their preference for pinning over warning, at least in the case of a single tab.

2
  • 1
    This is certainly the solution., The only downside, in Firefox at least, is that pinned tabs are always moved to the left. In my main window I have 8 pinned tabs that are always open. In the OP's case I'd pin a tab in another window for the long-running job
    – Chris H
    Aug 18, 2023 at 9:58
  • While I didn't test this (will do it now), I think this is the real reason. Still should be more clear for users, but what you say makes a lot of sense and it's well documented, thank you a lot
    – Devin
    Aug 18, 2023 at 16:41
41

Because the cons of disrupting the user's flow by always showing a dialog is too large. Tabs are not as precious, they are opened and closed as many times as needed during a session. Even if the user closed by mistake, there are several error reversal options: "Reopen closed tab", "Recently Closed", and even "History".

I could imagine a subset of users needing the feature when running critical webapps. Therefore the feature exists to serve that edge case. There is no need to default a feature that only benefits the minority.

3
  • 22
    For those few cases the webapp can tell the browser that is should display a dialog. w3schools.com/jsref/event_onbeforeunload.asp
    – Samuel
    Aug 17, 2023 at 19:11
  • I'm pretty much with you, but as you can read both in my original post as well as the edit, I mention this should be optional, but at least exist. To the very least... why does it exist for multiple tabs and not for a single tab (when multiple are open)?
    – Devin
    Aug 17, 2023 at 19:20
  • 2
    @Devin Because closing multiple tabs can't easily be undone. Closing a single tab can, simply by typing Ctrl+Shift+T. (And if that tab should've been protected from closing in the first place, as Samuel says there are APIs that web apps can use to declare that their tab shouldn't be closed without confirmation. If the single tab doesn't block closing, then making the user confirm an action they can just as easily undo is unnecessarily onerous.)
    – FeRD
    Aug 19, 2023 at 6:28
19

Browsers strive to be as easy to use and smooth as possible.

Look at browsers just being environments for running web apps (I'd argue, these days we don't really deal with websites or portals - browsers see them as apps, even if they're not PWA), they are supposed to be as undisruptive as possible, while allowing the apps control of the user flow.

When you're on your phone, for example, working on an app - there's no way for an app to prevent you from closing it, right? You just close it and the app has to deal with it. Apply the same logic here.

If I'm done reading an article online and want to close it - why ask me for confirmation? Even if it was a mistake, i can just reopen it and lose nothing. Now if I was filling up a form and didn't save it before closing, I could lose my data and that's when it would be a good idea to confirm closing. Browser has no idea which of those two cases this is, so it could ask every time, but that would be way too disruptive most of the time. That's why there are ways for an app to prevent some of these actions - like showing dialogs on navigating out of the page or closing the tab, but that's on the individual app, not the browser.

In general, all the apps should be ready for getting closed at any point and try preserve critical user data as much as possible. Same as mobile apps.

2
  • 3
    Good answer - maybe you could make the part about web pages being able to display the dialog more prominent. Like at the start "By default modern browsers allow any web page to display a warning dialog when closing the tab or leaving the page", because this is the most important fact the OP has most likely overlooked.
    – Falco
    Aug 17, 2023 at 12:37
  • 7
    @Falco It's hardly even a "modern" feature -- that ability has been around for decades.
    – Barmar
    Aug 17, 2023 at 14:52
9

Before getting into the why, let's establish that those modals that you mention are an error prevention measure. But are all errors equal? No. There are two types of errors: Slips and mistakes.

  • Slips can happen due to sudden changes on a repetitive task or habit (action slip) or a distraction/interruption (attention slip).

  • Mistakes can happen due to perception (Lack of information), decision (Stress, biased decisions, or being overconfident), or knowledge (Lack of knowledge and/or poor communication).

The task you describe (closing a tab) will, in most cases, fall under either an attention slip or a decision mistake.

Let me give you two distinct situations.

  • You are a security person at the entrance of a disco, clicking a button every time a person enters.
  • You are the president of a country and you are inspecting your nuclear missile suitcase.

The outcomes of an error in these situations are completely opposite on a severity scale: Counting an extra person, or blowing up a whole country. Then, should the error prevention methods you use be similar?

If you add too many error prevention measures for the security guard, it will add extra time to a task he has to repeat thousands of times a night. And an error is not that grave either, and easily fixable. As a simple solution, you could add another button that subtracts a person.

For the president, however, a simple error would be catastrophic and not fixable at all (unless we discover time travel). So for this action, it is best there top be a thousand bells and whistles to be clicked, secret codes, approval from different people, independent organizations, etc.

So going back to your case... what is the worst that can happen if you click on the "Close tab" button when you did not mean to? That you will lose a rather relevant website. Are there any prevention methods available? Luckily, the browser's UX designers have added a couple: You can right-click and press the "Undo close tab" or go to your history and search for that website.

So, in short:

TLDR: Humans make mistakes. As designers, we have to provide ways to prevent, minimize, or fix errors in a way that makes sense to the context and outcome.

I was trying to be very divulgation on my answer, but more specific to your point (as you are a professional):

Shcneiderman's Golden Rules

  1. Prevent errors. As much as possible, design the interface so that users cannot make serious errors; for example, gray out menu items that are not appropriate and do not allow alphabetic characters in numeric entry fields (Section 3.3.5). [...]

I would push that this error is not considered serious in terms of outcomes. Same answer for Nielsen's 5th Usability Heuristic.

  1. Permit easy reversal of actions. As much as possible, actions should be reversible. [...]

The action is reversible. Same answer for Nielsen's 9th Heuristic.

  1. Keep users in control. Experienced users strongly desire the sense that they are in charge of the interface and that the interface responds to their actions.

I don't understand what's your point on this one. Could you expand a little bit further?

I'm not aware of ISO 9241-110:2020 nor do I have access to it, so I can't comment on that front.

1
  • Good point about the severity scale. Definitely don't want any jive turkeys up in my disco!
    – Mentalist
    Aug 18, 2023 at 2:09
5

Beyond international rules or statutes, I believe that the behavior is still exactly the same as that of any application, and a browser is an application.

When opening a document or creating a new one in Excel, Word, Photoshop, or any application, if no change is made to them when closing the document window there is not any closing dialog alert, it would be somewhat redundant: Do you want to close the file where you have not made any changes?

In a browser, opening windows or tabs and then closing them should not have any alerts unless changes are made as in the case of forms

3
  • the thing is browsers allow closing tabs even if processes are running
    – Devin
    Aug 17, 2023 at 15:55
  • 3
    But the processes doesn't belong to the browser tab. In any case the alert should come from the Page where the process starts.
    – Danielillo
    Aug 17, 2023 at 17:54
  • indeed. But lousy coding exists and it's a reality. The effort to add user control should be negligible (I guess), hence my question
    – Devin
    Aug 17, 2023 at 19:21
2

If there is only one tab, then the close button is unambiguous. Close the browser (window)!

But if there is more than one tab, it is possible that an user will misinterpret the window close with the tab close actions, and thus try to close the current tab by clicking the window close button.

(This is especially a problem with modern conventions where tabs are placed on the title bar of most browsers)


Additionally, the web platform has a way for web-apps to communicate that they shouldn't be closed lightly. If the task the user is currently performing is important and shouldn't be disrupted, the website is supposed to tell the browser.

If the application does not tell the browser about data loss, then it is the application's fault, as in, it was not an intentional user experience choice to let the user easily lose data.

Browsers could instead require close confirmation if any form field has been filled, but that would be very annoying. A search bar query, for example, in the vast majority of cases, is disposable. Nevertheless, it is a filled form element, so the browser would have to notify the user.

Excessive notifications cause desensitisation, which reduces the value of legitimate notifications.


As for why the extra confirmation especially on the multi-tab case, it comes back to visibility. If there is a single tab open, then by logic deduction the user can see the contents and if they mean to close it or not!

(Bar things like other applications covering the content, which is a window manager concern, not the browser's)

However, if there are multiple tabs open, then the user cannot glance at all of them to know if they meant to close them, even though no data loss would happen.

2
  • 1
    "If there is only one tab, then the close button is unambiguous. Close the browser (window)!" I really hate this behaviour. If I close the last tab that doesn't mean I want to close the browser. If I want to close the browser I use it's close button and not the one of the tab. Aug 18, 2023 at 12:27
  • @TheincredibleJan I agree, but to be clear, in the answer I am always referring to the window close button, the tab close button being subjective is a related but different matter.
    – Kroltan
    Aug 18, 2023 at 15:01
1

If the page in the tab has unsaved data, it's up to the application behind that page to do this.

For instance, as I type this answer into ux.stackexchange.com, I can click on the X to close the tab. A dialog pops up.

This page is asking you to confirm that you want to leave — information you’ve entered may not be saved.

[ Leave Page ] [ Stay on Page ]

The feature you're asking for is essentially implemented. It's just up to each document to set up.

It would be pretty annoying to be prompted that you want to close a page that is only showing static content.

People sometimes have dozens, even hundreds of tabs; that's a lot of prompting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.