Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by whitelisting our website.
Posted inUncategorized

WebKit Always Enables the Copy Menu Item in Every App

Jeff Johnson:

Several weeks ago, John Gruber of Daring Fireball asked me
whether I could reproduce an issue he was seeing in Safari: when a
web page is focused, the Copy menu item in the main menu is always
enabled, regardless of whether there’s anything selected in the
web page. I could indeed reproduce that issue, and it turns out to
be the fault of WebKit. The issue also occurs in Mail app, when an
email message is focused.

On Apple platforms, WebKit is a public API, used by third-party
apps in addition to Apple’s first-party apps. RSS readers such as
NetNewsWire and Vienna, preferred by Gruber and
myself, respectively, use WebKit to display articles from RSS
feeds. And sure enough, both apps exhibit the same issue: the Copy
menu item is always enabled when an article is focused.

What happens if you copy and paste from a WebKit WebView with no
selection? Nothing happens, nothing is pasted. However,
technically speaking, the clipboard is not empty.

In most Mac apps, since the dawn of time, if there is nothing selected to be copied, the Edit → Copy (and Cut) commands are disabled. If you invoke the ⌘C shortcut while the Copy command is disabled, you hear an alert sound, letting you know that whatever you thought you were copying could not be copied because it wasn’t selected. That beep is useful context. This is proper behavior for all menu items — if they’re not available to do something, they should be disabled, and invoking a disabled menu item keyboard shortcut should beep. In any app that uses WebKit, since early in 2025, the Copy command is always enabled when a WebKit view has focus — but if nothing is selected, you get useless clipboard data that can’t actually be pasted anywhere. (And whatever was on your clipboard is now gone, or pushed back if you use a clipboard history utility.)

This is clearly a bug. It cannot be acceptable that you can copy nothing, wiping out whatever was previously on the clipboard. (Or to be pedantic, to copy a useless inscrutable plist blob that can’t be pasted anywhere.)

Johnson reported this bug in WebKit’s Bugzilla system, but it was erroneously closed as “Won’t Fix”. There’s a conflation in the WebKit team’s closing of Johnson’s bug report between how the Edit → Copy command behaves in any WebKit-using app, and how JavaScript’s document.execCommand("copy") needs to be available even when there’s no selection in the WebKit view. WebKit engineers introduced the bug in application behavior when they attempted to fix the decade-old bug in the JavaScript behavior last year.

I was very glad to read on the WebKit blog, just this morning, that the WebKit team is encouraging the submission of bug reports. Here’s a bug that has already been reported, with copious details, that they merely need to look at again.

Leave a Reply

Your email address will not be published. Required fields are marked *