lapcat / SafariExtensions

Resources for the development of Safari extensions
43 stars 3 forks source link

FB15714231 - Safari steals keyboard shortcuts from focused NSTextView in Safari app extension popup #53

Open lapcat opened 4 months ago

lapcat commented 4 months ago

When a Safari app extension popup view includes an NSTextView, and the text view is focused, Safari wrongly steals keyboard shortcuts that are mean for text selection and editing. For example, command-shift-down normally selects text to the end, but that also happens to be the keyboard shortcut for "Go to Next Tab Group". Unfortunately, when the user attempts to select text in the text view, it ends up switching tab groups instead. This affects my Safari app extension StopTheMadness Pro, the popup of which includes NSTextViews for entering custom CSS and JavaScript.

To reproduce this bug, you can actually use the same sample project as from the previous bug FB11843792 - Safari doesn't enable Paste and Match Style in extension popups https://github.com/lapcat/SafariExtensions/issues/13

Steps to reproduce

  1. Create a couple of tab groups in Safari
  2. Build, run, and enable the sample Xcode project PasteAndMatchStyleText
  3. Open the PasteAndMatchStyleText extension popup window
  4. Paste several lines of text into the popup's NSTextView
  5. Put the cursor in the first line of the NSTextView and press command-shift-down

Expected results: The text in the NSTextView is selected

Actual results: Safari goes to the next tab group.