Skip to content

revise updateState logic for ReactModalHostView (v2) - #46359

Closed
alanleedev wants to merge 2 commits into
react:mainfrom
alanleedev:export-D62286026
Closed

alanleedev wants to merge 2 commits into
react:mainfrom
alanleedev:export-D62286026

Conversation

@alanleedev

@alanleedev alanleedev commented Sep 6, 2024 •

Copy link
Copy Markdown
Contributor

Summary:
Remove unneeded code around size calculation and old arch support

  • updateState was getting called unnecessarily in multiple places --> only call from onSizeChanged()
    • this is a reliable source for getting the content size area of the dialog used for Modal
    • remove code checking duplicated update
  • Old architecture cleanup
    • Remove Java implementation of ShadowNode
      • we already have logic to set the node size via UIManagerModule::updateNodeSize(). This code is now group together in updateState() for both new and old architecture

This fixes issues with resulting from wrong size calculation:

  • having gaps at bottom when we set statusBarTranslucent to true
  • Modal cut off at bottom on Android 15 (drawn under bottom nav bar)

Changelog:
[Android][Fixed] - Modal statusBarTranslucent bug, Modal at bottom being cut off in Android 15 (without forced edge-to-edge)
[Android][Deprecation] - Deprecating ModalHostShadowNode and ModalHostHelper classes

Differential Revision: D62286026

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Sep 6, 2024
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62286026

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62286026

Summary:
Pull Request resolved: #46326

- renaming variabled to make intent more clear
    - `dialog` -> `dialogWindow` to distinguish with `activity.window`
    - `hostView` -> `dialogRootViewGroup` as name was confusing.
        - `ReactModalHostView` creates and manages `DialogRootViewGroup` but it used as contentView for the Dialog.
- bug fixes

Changelog: [Internal]

Differential Revision: D62177564

Reviewed By: mdvacca
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62286026

2 similar comments
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62286026

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62286026

Summary:
Pull Request resolved: #46359

Remove unneeded code around size calculation and old arch support
- updateState was getting called unnecessarily in multiple places --> only call from onSizeChanged()
    - this is a reliable source for getting the content size area of the dialog used for Modal
     - remove code checking duplicated update
- Old architecture cleanup
    - Remove Java implementation of ShadowNode
      - we already have logic to set the node size via UIManagerModule::updateNodeSize(). This  code is now group together in updateState() for both new and old architecture

This fixes issues with resulting from wrong size calculation:
- having gaps at bottom when we set `statusBarTranslucent` to `true`
- Modal cut off at bottom on Android 15 (drawn under bottom nav bar)

Changelog:
[Android][Fixed] - Modal statusBarTranslucent bug, Modal at bottom being cut off in Android 15 (without forced edge-to-edge)
[Android][Deprecation] - Deprecating ModalHostShadowNode and ModalHostHelper classes

Reviewed By: mdvacca

Differential Revision: D62286026
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62286026

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request has been merged in 77b3a8b.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Sep 7, 2024
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @alanleedev in 77b3a8b

When will my fix make it into a release? | How to file a pick request?

@mysport12

mysport12 commented Oct 17, 2024 •

Copy link
Copy Markdown
Contributor

Hi @alanleedev. I am running the latest RC (0.76.0-rc.6) and still have some problems with statusBarTranslucent={true} for Android modals.

<Modal
      animationType="slide"
      onRequestClose={onClose}
      presentationStyle="overFullScreen"
      statusBarTranslucent={true}
      transparent={true}
      visible={true}>
      {Modal content rendered here}
</Modal>

The modal doesn't draw under the status bar and additionally gives it a white background (at least that appears to be the case).

Screenshot_20241017-162736

After the modal is dismissed, the status bar remains visible.

Screenshot_20241017-162739

For reference, I am setting the status bar translucent with the StatusBar component provided by RN. If I instead use the StatusBar component to hide the status bar...

<StatusBar hidden={true} backgroundColor="transparent" barStyle={barStyle} translucent={true} />

...the modal problem does not show itself both when the modal is open and afterward.

Screenshot_20241017-162718

Screenshot_20241017-162722

Based on commit history, you seem to be the most familiar with this topic so I hope that you are able to look into it and help out! I appreciate any and all help you are able to provide!

EDIT: I am running on the new arch and these screens were captured via a physical Google Pixel 4 Android version 13 running locally

@alanleedev

Copy link
Copy Markdown
Contributor Author

@mysport12 Thanks for reporting.
Could you file a new issue with a Reproducer App?
Let me see if I understand correctly.
So when the Modal is visible status bar area turns white and goes back to normal after modal is dismissed?

@mysport12

Copy link
Copy Markdown
Contributor

Yeah I will try and get it posted tomorrow. The issue arises while the modal is visible and persists after it is closed. Only if I have the status bar hidden does the issue not show itself.

@mysport12

Copy link
Copy Markdown
Contributor

@alanleedev sorry for the alarm. Turns out I was missing a flag when using useAnimatedKeyboard from reanimated that was causing the status bar padding issue. Everything is good on the RN side.

@alanleedev

Copy link
Copy Markdown
Contributor Author

@mysport12 Great to hear everything is working as expected.

cipolleschi pushed a commit that referenced this pull request Feb 6, 2025
Summary:
Pull Request resolved: #46359

Remove unneeded code around size calculation and old arch support
- updateState was getting called unnecessarily in multiple places --> only call from onSizeChanged()
    - this is a reliable source for getting the content size area of the dialog used for Modal
     - remove code checking duplicated update
- Old architecture cleanup
    - Remove Java implementation of ShadowNode
      - we already have logic to set the node size via UIManagerModule::updateNodeSize(). This  code is now group together in updateState() for both new and old architecture

This fixes issues with resulting from wrong size calculation:
- having gaps at bottom when we set `statusBarTranslucent` to `true`
- Modal cut off at bottom on Android 15 (drawn under bottom nav bar)

Changelog:
[Android][Fixed] - Modal statusBarTranslucent bug, Modal at bottom being cut off in Android 15 (without forced edge-to-edge)
[Android][Deprecation] - Deprecating ModalHostShadowNode and ModalHostHelper classes

Reviewed By: mdvacca

Differential Revision: D62286026

fbshipit-source-id: 03b64a7783c12bebd1457c86a9a2657adc882c79
cipolleschi added a commit that referenced this pull request Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants