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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 'box-only' as a layoutOnlyProp #15529

Closed
wants to merge 1 commit into from

Conversation

tomasreimers
Copy link
Contributor

Currently, having the property pointerEvents={'box-only'} marks a view as layoutOnly. For optimization reasons, layoutOnly nodes are not added to the node hierarchy The problem is that should this box ever need to be transitioned to not-layout-only (for example, because you add the a CSS transform property), it must be added to the hierarchy. To add it to the hierarchy the React Styles Diff Map is passed along with the backing shadowNode to create the node. The problem is that at no point were the original pointerEvents and so the new node will be created with pointerEvents = 'auto'.

A more correct fix to this problem might be to have shadowNodes carry around their pointerEvents, although this is likely a greater design decision which is why am I proposing the quick fix now.

Will also resolve: react-native-modal/react-native-modal#11

Currently, having the property `pointerEvents={'box-only'}` marks a view as layoutOnly. For optimization reasons, layoutOnly nodes are [not added to the node hierarchy](https://github.com/facebook/react-native/blob/b103903ec869bc48dfcaf001dc926957d0b5200a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyOptimizer.java#L99) The problem is that should this box ever need to be [transitioned to not-layout-only](https://github.com/facebook/react-native/blob/b103903ec869bc48dfcaf001dc926957d0b5200a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyOptimizer.java#L394) (for example, because you add the a CSS transform property),  it must be added to the hierarchy. To add it to the hierarchy the [React Styles Diff Map](https://github.com/facebook/react-native/blob/b103903ec869bc48dfcaf001dc926957d0b5200a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyOptimizer.java#L396) is passed along with the backing shadowNode to create the node. The problem is that at no point were the original `pointerEvents` and so the new node will be created with `pointerEvents =  'auto'`.

A more correct fix to this problem might be to have shadowNodes carry around their pointerEvents, although this is likely a greater design decision which is why am I proposing the quick fix now.

Will also resolve: react-native-modal/react-native-modal#11
@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. GH Review: review-needed labels Aug 17, 2017
@pull-bot
Copy link

Warnings
⚠️

📋 Test Plan - This PR appears to be missing a Test Plan.

@facebook-github-bot label Needs more information

Generated by 🚫 dangerJS

@tomasreimers
Copy link
Contributor Author

tomasreimers commented Aug 20, 2017 via email

@mmazzarolo
Copy link

mmazzarolo commented Aug 22, 2017

+1 I can confirm this caused some headaches in the #11 react-native-modal issue 😄

@shergin
Copy link
Contributor

shergin commented Aug 23, 2017

I even don't understand how pointerEvents style logically can be connected to layout only nodes. 😞

@ide
Copy link
Contributor

ide commented Aug 23, 2017

I suspect pointerEvents are related because one of the reasons we'd create a real view (instead of only a shadow view) is so it can receive touch events. It seems to me there are two bugs in the logic.

We should check for some properties that always require a real view (ex: transform) and make sure they force layout-only to be false. We also should have the shadow views carry more information as mentioned in the first post above so that we can turn a layout-only view into a real view correctly.

@janicduplessis
Copy link
Contributor

Maybe just ship this as is and add a todo comment + issue to improve.

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Sep 8, 2017
@facebook-github-bot
Copy link
Contributor

@tomasreimers has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

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. Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tap outside to close
7 participants