Skip to content

Conversation

shwanton
Copy link

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

NSScrollView can have overlay style explicitly set.
https://developer.apple.com/documentation/appkit/nsscrollerstyle/nsscrollerstyleoverlay

Overlay style will not take up any space in the ContentView so content can be flush with insets.

Default uses the legacy style, not the overlay.

Changelog

[macOS] [ADDED] - Add ScrollView Indicator Overlay style

Test Plan

Overlay style can be enable/disabled

CleanShot.2023-01-17.at.15.34.10.mp4

@Saadnajmi
Copy link
Collaborator

This PR would allow you to override the system preference and set your own default? @chiuam sounds useful 😅

Copy link

@analysis-bot analysis-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code analysis results:

  • eslint found some issues. Run yarn lint --fix to automatically fix problems.

@ghost ghost removed the Needs: Author Feedback label Jan 18, 2023
@shwanton
Copy link
Author

This PR would allow you to override the system preference and set your own default? @chiuam sounds useful 😅

This does allow user to override the system preference and always have overlay style enabled.

CleanShot.2023-01-17.at.16.37.02.mp4

@shwanton shwanton marked this pull request as ready for review January 18, 2023 00:43
@shwanton shwanton requested a review from a team as a code owner January 18, 2023 00:43
@chiuam chiuam merged commit 20e73d5 into microsoft:main Jan 18, 2023
@shwanton shwanton deleted the add-scrollview-indicator-overlay-style-prop branch January 20, 2023 02:26
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
shwanton added a commit to shwanton/react-native-macos that referenced this pull request Apr 27, 2024
Summary:
**Context**
- Issue reported here: https://fb.workplace.com/groups/647800172811209/permalink/1422946668629885/
- D43292504 synced [changes from OSS](microsoft#1658) where we added support for always showing the scroll indicator as overlay, even when the system setting was "always".
- When the system settings were changed, the [preferredScrollerStyleDidChange](https://www.internalfb.com/code/fbsource/[c827f358997c]/third-party/microsoft-fork-of-react-native/react-native-macos/packages/react-native/React/Views/ScrollView/RCTScrollView.m?lines=1348-1351) notification was overriding the `scrollView.scrollerStyle` back to `NSScrollerStyleLegacy`
- The issue was that we were only setting the overlay style on the underlying scrollView, but never saving it to the RCTScrollView. As a result, there was no reliable way to determine whether the overlay style had been saved or not.

https://www.internalfb.com/code/fbsource/[c827f358997c70a3c49f80c55915c28bdab9b97f][history]/third-party/microsoft-fork-of-react-native/react-native-macos/packages/react-native/React/Views/ScrollView/RCTScrollView.m?lines=549-556

**Change**
- Ensure that the overlay style indicator setting is saved to the `RCTScrollView`
- If `hasOverlayStyleIndicator` is true, manually set the scrollview to `NSScrollerStyleOverlay` and override the system setting

Test Plan:
|Paper|
| https://pxl.cl/4d7DN|

Reviewers: chpurrer, lefever, #rn-desktop

Reviewed By: chpurrer

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants