Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for macOS legacy scroller system setting. #262

Merged
merged 4 commits into from
Mar 23, 2020

Conversation

tom-un
Copy link
Collaborator

@tom-un tom-un commented Mar 23, 2020

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native 馃憤
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native 馃憤
  • 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

macOS scroll views are usually like iOS scroll views in that the scroll indicators only appear when scrolling and they overlay the content view. But in System Preferences > General, the user may choose 'Show scroll bars: Always' in which case the content view shrinks and a horizontal and/or vertical scroll indicator appears to the right and/or below the content view. In these cases the react-native content area was still being laid out as if the content view was the same size as the scroll view which would could cause the vertical scroll indicator to appear because the content was too wide.

This fix involves a change to the RCTScrollContentView reactSetFrame: method. When the react frame is being set, the method checks if the scrollerStyle property on the NSScrollView is NSScrollerStyleLegacy. If so it gets the width and height of the scrollers if visible and adjusts the frame size.

When the user changes the setting in System Preferences a NSPreferredScrollerStyleDidChangeNotification notification is sent. When this notification is sent, a react native event is fired to the onPreferredScrollerStyleDidChange prop of <ScrollView>. The javascript implementation of ScrollView handles the event and forces a re-render.

scroller

Focus areas to test

The RNTester app was used to validate the change with attention to the Scroll and List examples.

Microsoft Reviewers: Open in CodeFlow

@tom-un tom-un requested a review from HeyImChris March 23, 2020 00:40
@tom-un tom-un requested a review from acoates-ms as a code owner March 23, 2020 00:40
@tom-un tom-un requested a review from tido64 March 23, 2020 00:42
React/Views/ScrollView/RCTScrollContentView.m Outdated Show resolved Hide resolved
React/Views/ScrollView/RCTScrollContentView.m Outdated Show resolved Hide resolved
React/Views/ScrollView/RCTScrollContentView.m Outdated Show resolved Hide resolved
React/Views/ScrollView/RCTScrollView.m Outdated Show resolved Hide resolved
@tom-un tom-un merged commit d604a2d into microsoft:master Mar 23, 2020
@tom-un tom-un deleted the tomun/scrollview-layout branch May 8, 2020 21:49
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.

None yet

5 participants