diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 4b526d274..324128a0c 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -2730,7 +2730,7 @@ setBoundsOrigin: doesItFitForWidth = documentViewVisibleRect.size.width >= rectInDocumentView.size.width; // One of the following has to be true since our current visible rect didn't contain aRect. - if (rectInDocumentViewMinX < rectInDocumentViewMinX && doesItFitForWidth) + if (rectInDocumentViewMinX < documentViewVisibleRectMinX && doesItFitForWidth) // Scroll to left edge of aRect as it is to the left of the visible rect and it fit inside scrollPoint.x = rectInDocumentViewMinX; else if (CGRectGetMaxX(rectInDocumentView) > CGRectGetMaxX(documentViewVisibleRect) && doesItFitForWidth) diff --git a/Tests/AppKit/CPScrollViewTest.j b/Tests/AppKit/CPScrollViewTest.j index 40a92749e..320ecb263 100644 --- a/Tests/AppKit/CPScrollViewTest.j +++ b/Tests/AppKit/CPScrollViewTest.j @@ -229,7 +229,7 @@ [scrollView setDocumentView:documentView]; - [textField1 setFrameOrigin:CGPointMake(0, 0)]; + [textField1 setFrameOrigin:CGPointMake(10, 10)]; [textField2 setFrameOrigin:CGPointMake(500, 500)]; [documentView addSubview:textField1]; @@ -260,7 +260,7 @@ visibleRect = [documentView visibleRect]; // We should now be back at top left corner - [self assertPoint:CGPointMake(0, 0) equals:visibleRect.origin message:@"VisibleRect origin not at top left corner again"]; + [self assertPoint:CGPointMake(10, 10) equals:visibleRect.origin message:@"VisibleRect origin not at top left corner again"]; // Try to scroll again and it should not scroll hasScrolled = [textField1 scrollRectToVisible:[textField1 bounds]];