Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ exports[`AppRegistry runApplication styles roots in different documents 1`] = `
".r-bottom-1p0dtai {bottom: 0px;}",
".r-left-1d2f490 {left: 0px;}",
".r-pointerEvents-105ug2t {pointer-events: auto !important;}",
".r-pointerEvents-12vffkv * {pointer-events: auto;}",
".r-pointerEvents-12vffkv>* {pointer-events: auto;}",
".r-pointerEvents-12vffkv {pointer-events: none !important;}",
".r-pointerEvents-633pao * {pointer-events: none;}",
".r-pointerEvents-633pao>* {pointer-events: none;}",
".r-pointerEvents-633pao {pointer-events: none !important;}",
".r-pointerEvents-ah5dr5 * {pointer-events: none;}",
".r-pointerEvents-ah5dr5>* {pointer-events: none;}",
".r-pointerEvents-ah5dr5 {pointer-events: auto !important;}",
".r-position-u8s1d {position: absolute;}",
".r-right-zchlnj {right: 0px;}",
Expand All @@ -44,11 +44,11 @@ exports[`AppRegistry runApplication styles roots in different documents 2`] = `
".r-bottom-1p0dtai {bottom: 0px;}",
".r-left-1d2f490 {left: 0px;}",
".r-pointerEvents-105ug2t {pointer-events: auto !important;}",
".r-pointerEvents-12vffkv * {pointer-events: auto;}",
".r-pointerEvents-12vffkv>* {pointer-events: auto;}",
".r-pointerEvents-12vffkv {pointer-events: none !important;}",
".r-pointerEvents-633pao * {pointer-events: none;}",
".r-pointerEvents-633pao>* {pointer-events: none;}",
".r-pointerEvents-633pao {pointer-events: none !important;}",
".r-pointerEvents-ah5dr5 * {pointer-events: none;}",
".r-pointerEvents-ah5dr5>* {pointer-events: none;}",
".r-pointerEvents-ah5dr5 {pointer-events: auto !important;}",
".r-position-u8s1d {position: absolute;}",
".r-right-zchlnj {right: 0px;}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ describe('AppRegistry', () => {
.r-left-1d2f490{left:0px;}
.r-maxWidth-dnmrzs{max-width:100%;}
.r-pointerEvents-105ug2t{pointer-events:auto!important;}
.r-pointerEvents-12vffkv * {pointer-events:auto;}
.r-pointerEvents-12vffkv>* {pointer-events:auto;}
.r-pointerEvents-12vffkv{pointer-events:none!important;}
.r-pointerEvents-633pao * {pointer-events:none;}
.r-pointerEvents-633pao>* {pointer-events:none;}
.r-pointerEvents-633pao{pointer-events:none!important;}
.r-pointerEvents-ah5dr5 * {pointer-events:none;}
.r-pointerEvents-ah5dr5>* {pointer-events:none;}
.r-pointerEvents-ah5dr5{pointer-events:auto!important;}
.r-position-u8s1d{position:absolute;}
.r-right-zchlnj{right:0px;}
Expand Down Expand Up @@ -120,11 +120,11 @@ describe('AppRegistry', () => {
.r-left-1d2f490{left:0px;}
.r-maxWidth-dnmrzs{max-width:100%;}
.r-pointerEvents-105ug2t{pointer-events:auto!important;}
.r-pointerEvents-12vffkv * {pointer-events:auto;}
.r-pointerEvents-12vffkv>* {pointer-events:auto;}
.r-pointerEvents-12vffkv{pointer-events:none!important;}
.r-pointerEvents-633pao * {pointer-events:none;}
.r-pointerEvents-633pao>* {pointer-events:none;}
.r-pointerEvents-633pao{pointer-events:none!important;}
.r-pointerEvents-ah5dr5 * {pointer-events:none;}
.r-pointerEvents-ah5dr5>* {pointer-events:none;}
.r-pointerEvents-ah5dr5{pointer-events:auto!important;}
.r-position-u8s1d{position:absolute;}
.r-right-zchlnj{right:0px;}
Expand Down Expand Up @@ -172,11 +172,11 @@ describe('AppRegistry', () => {
.r-left-1d2f490{left:0px;}
.r-maxWidth-dnmrzs{max-width:100%;}
.r-pointerEvents-105ug2t{pointer-events:auto!important;}
.r-pointerEvents-12vffkv * {pointer-events:auto;}
.r-pointerEvents-12vffkv>* {pointer-events:auto;}
.r-pointerEvents-12vffkv{pointer-events:none!important;}
.r-pointerEvents-633pao * {pointer-events:none;}
.r-pointerEvents-633pao>* {pointer-events:none;}
.r-pointerEvents-633pao{pointer-events:none!important;}
.r-pointerEvents-ah5dr5 * {pointer-events:none;}
.r-pointerEvents-ah5dr5>* {pointer-events:none;}
.r-pointerEvents-ah5dr5{pointer-events:auto!important;}
.r-position-u8s1d{position:absolute;}
.r-right-zchlnj{right:0px;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('StyleSheet/compile', () => {
],
[
[
".r-pointerEvents-ah5dr5 * {pointer-events:none;}",
".r-pointerEvents-ah5dr5>* {pointer-events:none;}",
".r-pointerEvents-ah5dr5{pointer-events:auto!important;}",
],
3,
Expand Down Expand Up @@ -191,7 +191,7 @@ describe('StyleSheet/compile', () => {
[
[
[
".r-pointerEvents-633pao * {pointer-events:none;}",
".r-pointerEvents-633pao>* {pointer-events:none;}",
".r-pointerEvents-633pao{pointer-events:none!important;}",
],
3,
Expand All @@ -215,7 +215,7 @@ describe('StyleSheet/compile', () => {
[
[
[
".r-pointerEvents-12vffkv * {pointer-events:auto;}",
".r-pointerEvents-12vffkv>* {pointer-events:auto;}",
".r-pointerEvents-12vffkv{pointer-events:none!important;}",
],
3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,15 @@ function createAtomicRules(identifier: string, property, value): Rules {
} else if (value === 'none') {
finalValue = 'none!important';
const block = createDeclarationBlock({ pointerEvents: 'none' });
rules.push(`${selector} * ${block}`);
rules.push(`${selector}>* ${block}`);
} else if (value === 'box-none') {
finalValue = 'none!important';
const block = createDeclarationBlock({ pointerEvents: 'auto' });
rules.push(`${selector} * ${block}`);
rules.push(`${selector}>* ${block}`);
} else if (value === 'box-only') {
finalValue = 'auto!important';
const block = createDeclarationBlock({ pointerEvents: 'none' });
rules.push(`${selector} * ${block}`);
rules.push(`${selector}>* ${block}`);
}
const block = createDeclarationBlock({ pointerEvents: finalValue });
rules.push(`${selector}${block}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,11 @@ const createDOMProps = (elementType, props, options) => {
`props.pointerEvents is deprecated. Use style.pointerEvents`
);
}
const pointerEventsValue =
StyleSheet.flatten(style).pointerEvents || pointerEvents;
Copy link
Owner

Choose a reason for hiding this comment

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

My concern here is that this has a good chance of regressing performance because we're flattening the styles before resolving them. That's probably why the special handling of the pointerEvent prop wasn't ported.

It's been a while since I've looked at the e2e benchmarks but that would be the way to confirm this. Might be a good idea to separate the fix for the pointerEvents behavior from the attempt to support inline styles pointerEvent. The latter is an edge case that can easily be avoided by changes to product code anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I get the concern. I can remove the code to fix the inline style issue in this PR, but I still think it should be done, especially because nobody is aware of the difference in the pointerEvents behaviour. Even the React Native docs say that a plain JS object is fine for styling, and suggest using StyleSheet.create only for more complex scenarios. That's why I think that the issue should be solved in the react-native-web library.

In that case could you run the e2e tests to confirm that the solution causes performance regressions? I'm not sure what's the complexity of the flatten method, but there is always a chance to improve the code. I noticed that the props.style is passed as style[2] for the View component. If it's the same for all other components, we could look for the pointerEvents value only there. If it's an object we get O(1), but, even if in the client app the style prop gets passed by an array of style objects we can iterate in O(n) complexity to find the pointerEvents there.

Copy link
Owner

Choose a reason for hiding this comment

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

A plain js object for styling is not fast enough for web. Doesn't matter what RN says

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I meant is that if the docs say that it's fine to use plain JS objects people will follow this instruction anyways. That's why I think it is should be covered. Maybe there should be at least a warning in the console to provide some feedback to the library users that something might not work as expected.

I've removed the code from the PR so it includes only the fix for the incorrect pointerEvents propagation


const [className, inlineStyle] = StyleSheet(
[style, pointerEvents && pointerEventsStyles[pointerEvents]],
[style, pointerEventsValue && pointerEventsStyles[pointerEventsValue]],
{
writingDirection: 'ltr',
...options
Expand Down