Skip to content

Conversation

Saadnajmi
Copy link
Collaborator

@Saadnajmi Saadnajmi commented Apr 22, 2022

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos 👍
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos 👍
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Summary

Based on your system preferences, NSScrollView may or may not always show it's scrollbars. When the scrollbars are shown, the content view of the scroll view is smaller than the scroll view itself, depending on whether we show a horizontal scrollbar, a vertical one, or both. Yoga doesn't know about this shrinking of content view's size, so we get around this by adding padding to the content view if scroll bars are visible.

The issue was, we would add padding for both horizontal and vertical scrollbars, event if only one or the other was shown. We fix that here with this change. Previously we passed the entire NSScroller (both vertical and horizontal) to RCTScollContentLocalData so that we could read the height/width. According to Apple documentation, an NSScroller may be allocated even if it's not shown. So, instead of passing the whole scroller, let's just see if it's shown and pass the width/height instead.

Changelog

[macOS] [Fixed] - ScrollView - Don't always adjust content view padding for both scrollers

Test Plan

Ran RN-Tester and scrollviews appeared as expected.

@Saadnajmi Saadnajmi requested a review from a team as a code owner April 22, 2022 20:16
@huwilkes
Copy link

Nit: "NSScroller may be allovated" -> allocated

@Saadnajmi Saadnajmi merged commit bf29e41 into microsoft:main Apr 22, 2022
@Saadnajmi Saadnajmi deleted the scrollview-fix branch April 22, 2022 23:41
Saadnajmi added a commit to Saadnajmi/react-native-macos that referenced this pull request Apr 23, 2022
…ers (microsoft#1132)

* Only pass height or width if needed

* fix typo

* Update RCTScrollContentLocalData.h
Saadnajmi added a commit to Saadnajmi/react-native-macos that referenced this pull request Apr 23, 2022
…ers (microsoft#1132)

* Only pass height or width if needed

* fix typo

* Update RCTScrollContentLocalData.h
Saadnajmi added a commit to Saadnajmi/react-native-macos that referenced this pull request Apr 23, 2022
…ers (microsoft#1132)

* Only pass height or width if needed

* fix typo

* Update RCTScrollContentLocalData.h
Saadnajmi added a commit to Saadnajmi/react-native-macos that referenced this pull request Apr 23, 2022
…ers (microsoft#1132)

* Only pass height or width if needed

* fix typo

* Update RCTScrollContentLocalData.h
Saadnajmi added a commit that referenced this pull request Apr 23, 2022
…ers (#1132) (#1133)

* Only pass height or width if needed

* fix typo

* Update RCTScrollContentLocalData.h
shwanton pushed a commit to shwanton/react-native-macos that referenced this pull request Feb 13, 2023
…h scrollers (microsoft#1132) (microsoft#1133)"

This reverts commit f5622ec.

# Conflicts:
#	React/Views/ScrollView/RCTScrollContentView.m
shwanton added a commit to shwanton/react-native-macos that referenced this pull request Feb 13, 2023
Summary:
## Sync OS changes for ScrollBar

[[ScrollView] Don't always adjust content view padding for both scrollers microsoft#1132](microsoft#1132)

[ScrollView - Respect the shows<Horizontal | Vertical>ScrollIndicator props on macOS microsoft#1135](microsoft#1135)

[Remove horizontal scrollview indicator padding when empty microsoft#1635](microsoft#1635)

[Add ScrollView Indicator Overlay style microsoft#1658](microsoft#1658)

NOTE: This will override the "Always" user setting and force the scrollview to use the overlay style instead

{F850963270}


Test Plan:
|ScrollView Overlay Style|
|https://pxl.cl/2qp0D|

|ScrollView works correctly|
|https://pxl.cl/2qpd1|

Reviewers: chpurrer, lefever

Reviewed By: chpurrer

Differential Revision: https://phabricator.intern.facebook.com/D42637723
shwanton pushed a commit to shwanton/react-native-macos that referenced this pull request Mar 10, 2023
…h scrollers (microsoft#1132) (microsoft#1133)"

This reverts commit f5622ec.

# Conflicts:
#	React/Views/ScrollView/RCTScrollContentView.m
shwanton added a commit to shwanton/react-native-macos that referenced this pull request Mar 10, 2023
Summary:
## Sync OS changes for ScrollBar

[[ScrollView] Don't always adjust content view padding for both scrollers microsoft#1132](microsoft#1132)

[ScrollView - Respect the shows<Horizontal | Vertical>ScrollIndicator props on macOS microsoft#1135](microsoft#1135)

[Remove horizontal scrollview indicator padding when empty microsoft#1635](microsoft#1635)

[Add ScrollView Indicator Overlay style microsoft#1658](microsoft#1658)

NOTE: This will override the "Always" user setting and force the scrollview to use the overlay style instead

{F850963270}


Test Plan:
|ScrollView Overlay Style|
|https://pxl.cl/2qp0D|

|ScrollView works correctly|
|https://pxl.cl/2qpd1|

Reviewers: chpurrer, lefever

Reviewed By: chpurrer

Subscribers: generatedunixname89002005327315

Differential Revision: https://phabricator.intern.facebook.com/D42637723
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants