-
-
Notifications
You must be signed in to change notification settings - Fork 987
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 view flattening error for Text
component
#3338
base: main
Are you sure you want to change the base?
Conversation
apple/RNGestureHandlerModule.mm
Outdated
if (auto v = dynamic_pointer_cast<const ParagraphShadowNode>(shadowNode); v != nullptr) { | ||
isTextComponent = true; | ||
} | ||
|
||
if (auto v = dynamic_pointer_cast<const TextShadowNode>(shadowNode); v != nullptr) { | ||
isTextComponent = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Is
isFormsStackingContext
false in both cases or only in the second one? - If in both, can this be a single if (
v != nullptr
is not necessary,nullptr
is falsy)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it is true
in first case and false
in second. Also, this if
statement is adapted from docs, but I can change it.
What do you think about returning jsi::Value(true)
, instead of assigning to another variable? It could be cleaner, but less readable at the same time so I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it is true in first case and false in second
In which case the error is thrown then?
Also, this if statement is adapted from docs, but I can change it.
I'd change it to stay consistent with RN and other libraries.
What do you think about returning jsi::Value(true), instead of assigning to another variable? It could be cleaner, but less readable at the same time so I'm not sure.
That works, we can also consider changing the name of the function at this point, as it does a wider check than the name suggests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which case the error is thrown then?
It is thrown when we have nested Text
components, i.e. we have TextShadowNode
. We can remove if
with ParagraphShadowNode
as error is not thrown in that case.
I'd change it to stay consistent with RN and other libraries.
Sure, I'll do it
That works, we can also consider changing the name of the function at this point, as it does a wider check than the name suggests.
What about canBeViewFlattened
, since this is the reason why we perform this check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partially done in 393b377
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More info in this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about canBeViewFlattened, since this is the reason why we perform this check?
Okay, now when I think about it it doesn't work, as it returns exactly the opposite. What about one of these:
disallowsViewFlattening
isFlatteningDisabled
|
||
return jsi::Value(isFormsStackingContext); | ||
const char *componentName = shadowNode->getComponentName(); | ||
bool isTextComponent = strcmp(componentName, "Paragraph") == 0 || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, does this happen in both cases or only for Text
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered here
Okay, I've managed to find out what's going on on both platform, hopefully this will answer your questions, @j-piasecki 😅 First, these are values of
in case of single When it comes to nested Given those information, on |
I think we can leave checks for both everywhere. The difference would be confusing in the future with no context. |
I agree, done in 39cf55b |
Description
Right now our
Text
components causes error thatGestureDetector
received view that may be view flattened. Addingcollapsable
intoText
is not possible, so we decided to remove the error.Android check is different because using
dynamic_pointer_cast
yieldsfalse
, even though in debuggershadowNode
can be seen asTextShadowNode
.Also, I've decided to use Android Studio formatter, to make sure that everyone in the team will have the same results.
Test plan
Tested on Nested Text example.