I’m wondering if anyone else has encountered what appears to be a long-standing Safari bug, going back at least a couple of major macOS releases.
I often have two or three Safari windows open, each with multiple tabs. Sometimes, but not always, if I have a YouTube video in the active tab and then attempt to close the tab using ⌘W, the entire window closes, not just the intended tab. It happens often enough that I’ve noticed that it always involves a YouTube video as the tab I want to close, but it happens sporadically enough that I cannot reliably repeat the bug on demand.
Internet searching hasn’t turned up much information, but an A.I. query suggested that it is a known issue that occurs when script-heavy pages slow down and interfere with “dynamic menu mapping” in Safari, making Safari behave like the window only has one tab.
The A.I. suggested creating an explicit Safari keyboard shortcut that sets ⌘W to mean “close tab”. I’m trying that, but I do wonder if anyone else has encountered this issue or knows of a better fix.