Ask
17

Why do browsers let you close a tab instantly but ask before closing the window?

Closing a single tab happens immediately and silently, even if there is a half-written message in it. Closing a window with several tabs often produces a confirmation. Some browsers let you enable a warning for the single-tab case but it is off by default and buried.

Given how easy it is to close the wrong tab, and how much can be lost, the default seems like the wrong way round to me. What is the reasoning?

4 answers Share
Report

Answering anonymously — a moderator will review it first.

  • @research_rosa · 3w ago

    The reasoning is that tabs are opened and closed constantly and windows are not, so the two actions have completely different frequencies.

    A typical session involves opening and closing dozens of tabs. Adding a confirmation to that would mean dozens of interruptions per session to protect against an occasional mistake, and a dialog that appears that often stops being read within a day. You would train people to dismiss it reflexively, at which point it protects nothing and costs everything.

    Closing a window is rarer and destroys more, so the ratio flips and a confirmation earns its place.

    This is the general principle behind when to confirm anything: the cost of a confirmation is paid on every correct action, and the benefit is collected only on incorrect ones. Frequent actions should almost never confirm.

    25
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
  • @frontend_felix · 3w ago

    The other half is that browsers chose undo over prevention, which is nearly always the better answer when it is available.

    Reopening a closed tab is one keystroke, works several tabs back, and restores scroll position and often form state. Session restore brings back an entire window after a crash. Recently closed lists go back further still.

    Once recovery is that cheap and that reliable, a confirmation dialog is strictly worse: it interrupts everyone to prevent something that can be undone in half a second.

    Which is a good general lesson for anyone designing anything. If you can make the action recoverable, do that instead of making it confirmable.

    22
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
  • @shortcut_shreya · 3w ago

    There is a targeted exception that already exists and does exactly what you want: a page with unsaved input can ask the browser to warn before it is closed.

    That is why closing a tab with a half-written message in some webmail clients does prompt you, while closing a tab showing an article does not. The decision is delegated to the page, which is the only party that knows whether anything would be lost.

    Browsers have progressively tightened this because it was abused — sites used it to keep people from leaving — so the dialog is now generic, cannot be customised, and only appears if the user has actually interacted with the page. That constraint is itself a nice illustration of what happens to any interruption mechanism that gets misused.

    18
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
  • @wireframe_wren · 3w ago

    Worth noting the design change that solved this better than any dialog: pinned tabs.

    Pinning shrinks the tab, moves it to the left, and in most browsers removes the close button entirely. That is prevention through affordance rather than through interruption — the accidental close becomes physically harder rather than verbally discouraged.

    If a tab matters to you, pinning it is a far better answer than wishing for a confirmation on all of them.

    11
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report