Repository navigation
fix(macos): keep Dimensions in step with the window - #3142
Open
Bron Davies (brondavies) wants to merge 1 commit into
Open
Bron Davies (brondavies) wants to merge 1 commit into
Bron Davies (brondavies) wants to merge 1 commit into
Conversation
Dimensions.get("window") and useWindowDimensions() could stay at their first value however the window was resized, and reported the frame rather than the content area:
- the module observes the frame of the window that was key when it was created, which is usually none, so no resize was ever reported. It now observes NSWindowDidResizeNotification.
- the size reported was the frame, title bar included. It is now the content rect, which is what the root view gets.
- with no key window (the app in the background) it fell back to the screen size, or published nothing. It now falls back to the main window, then the frontmost visible non-panel window, and publishes a resize made in the background.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Fixes #3139. Related: #915, #2296.
On macOS,
Dimensions.get('window')anduseWindowDimensions()stayed at their first value however the window was resized, and reported the frame rather than the content area. InRCTDeviceInfo:RCTReactNativeFactorymakes the window key after starting React Native. It now also observesNSWindowDidResizeNotification.frame.size, title bar included. It now reports the content rect, which is what the root view gets.NSApp.mainWindow, then the frontmost visible window that isn't a panel, and publishes a change made while the app is in the background, since a Mac app's window stays on screen then.This covers #2296's case inside
RCTDeviceInfo, without changing whatRCTKeyWindow()returns elsewhere.Test Plan:
RNTester-macOS (Debug, arm64, Xcode 27.1, macOS 26.6.2, 1512 x 982 display), Playground showing
useWindowDimensions():mainopen -g)On
main, bringing the window to the front then reported 700 x 600 (the frame), and a resize to 900 x 650 while in front left it at 700 x 600. The resizes were made through the Accessibility API.