Skip to content

Instantly share code, notes, and snippets.

@krzyzanowskim
Created November 17, 2025 06:19
Show Gist options
  • Select an option

  • Save krzyzanowskim/d2c5d41b86096ccb19b110cf7a5514c8 to your computer and use it in GitHub Desktop.

Select an option

Save krzyzanowskim/d2c5d41b86096ccb19b110cf7a5514c8 to your computer and use it in GitHub Desktop.
FB21059465: NSScrollView horizontal floating subview does not respect insets

The horizontal floating subview, when added to the NSScrollView, like with the snippet below, erroneusly adds the top inset twice (see attached screenshot). The floating subviews container view is not located at the begining of the safe content, but instead is located lower. That is not happening for the vertical floating subview:

        let scrollView: NSScrollView = ...
        scrollView.automaticallyAdjustsContentInsets = true // default
        let subview = NSView(frame: CGRect(x: 0, y: 0, width: 20, height: 20))
        subview.wantsLayer = true
        subview.layer?.backgroundColor = NSColor.red.cgColor
        scrollView.addFloatingSubview(subview, for: .horizontal)

Please check attached Xcode project that reproduce the issue. The red rectangle on the view should be located at the same origin as the text view in its view hirarchy.

Screenshot 2025-11-17 at 14 47 17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment