Skip to content

Conversation

Saadnajmi
Copy link
Collaborator

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

React Native's ScrollView component defines two props for iOS and Android: showsVerticalScrollIndicator and showsHorizontalScrollIndicator. These are designed to be user overridable (I.E: the user could make a vertical scrolling list that never shows a vertical indicator). macOS has equivalent props: hasVerticalScroller and hasVerticalScroller, but we would set them ourselves in code and not respect the user choice. We can simplify our code and respect the user choice by removing bits where we manually set whether our scroll view has vertical and horizontal scrollers or not. I also set autoHidesScrollbars = true to better match the existing behavior and because I think it's a better default to have.

Changelog

[macOS] [Fixed] - ScrollView respects props showsVerticalScrollIndicator, showsHorizontalScrollIndicator

Test Plan

I tested various different configurations of Scrollbars, making use of the existing Scrollindicators test". One thing to note is that macOS has 2 types of scrollbars that you can switch between in user preferences:

  • Legacy: Scrollbars that appear at the trailing end of the content view in a dedicated space.
  • Overlay: iOS style scrollbars that are overlaid on top of the content view.

I made sure that the proper margins are set so that the content view is sized appropriately based on which scrollbars are current. I also tested fixed size vs variable size scrollviews by locally hardcoding a size in RNTester.

Screen.Recording.2022-04-25.at.4.13.10.AM.mov

@harrieshin
Copy link

why isn't ios and macos property aligned? macOS can't just use "showsVerticalScrollIndicator" instead?

@Saadnajmi
Copy link
Collaborator Author

why isn't ios and macos property aligned? macOS can't just use "showsVerticalScrollIndicator" instead?

They are aligned? Setting "showsVerticalScrollIndicator" will internally set "hasVerticalScroller" on NSScrollView. Before we would overwrite that value everytime you lay out the scroll view, which we don't do anymore after this PR.

@harrieshin
Copy link

hasVerticalScroller

ah i misunderstood. hasVerticalScroller is actually a NSScrollView property not our own custom property

@Saadnajmi Saadnajmi merged commit 78b696c into microsoft:main Apr 25, 2022
@Saadnajmi Saadnajmi deleted the respect-scrollbar-props branch April 26, 2022 22:47
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 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.

2 participants