Repository navigation
Conversation
When updating accessibility text size there is an issue in the current code that would cut the tree enumeration and not update all the shadownodes in the tree - causing the layout in parent elements (of the text element) to not update its layout. This commit fixes this by simplifying the code a lot - we don't need any optimizations here - we can update the whole tree each time the system font size is changed. Tested in RN Tester and Expo Go (with the `enableFontScaleChangesUpdatingLayout` feature flag enabled)
| void SurfaceHandler::dirtyMeasurableNodes(std::shared_ptr<const ShadowNode> node) const { | ||
| if (auto* layoutableNode = dynamic_cast<const YogaLayoutableShadowNode*>(node.get())) { | ||
| // Only cast away const where needed | ||
| const_cast<YogaLayoutableShadowNode*>(layoutableNode)->dirtyLayout(); |
There was a problem hiding this comment.
I'm not sure if it's safe to dirty a potentially sealed node.
There was a problem hiding this comment.
I think this was what was done previously as well? I couldn't find a place where we checked for sealed or not in the previous code.
There was a problem hiding this comment.
Previously, the node was cloned before marking it as dirty - the new node is always unsealed.
You also can't really check if a node is sealed or not, since that information is preserved only in debug builds.
| if (!nodeHasChildren && !isMeasurableYogaNode) { | ||
| return nullptr; | ||
| void SurfaceHandler::dirtyMeasurableNodes(std::shared_ptr<const ShadowNode> node) const { | ||
| if (auto* layoutableNode = dynamic_cast<const YogaLayoutableShadowNode*>(node.get())) { |
There was a problem hiding this comment.
We might check the traits before trying the dynamic cast - I believe this would be faster than trying to call dynamic_cast if we'd like to optimize this further (I left optimization out since this is a thing that doesn't happen that often)
| return nullptr; | ||
| void SurfaceHandler::dirtyMeasurableNodes(std::shared_ptr<const ShadowNode> node) const { | ||
| if (auto* layoutableNode = dynamic_cast<const YogaLayoutableShadowNode*>(node.get())) { | ||
| // Only cast away const where needed |
There was a problem hiding this comment.
I'll remove this comment, it is not valid.
|
This fix was wrong - started to mutate the shadow tree in the completely wrong way. |
Summary:
When updating accessibility text size there is an issue in the current code that would cut the tree enumeration and not update all the shadownodes in the tree - causing the layout in parent elements (of the text element) to not update its layout.
This commit fixes this by simplifying the code a lot - we don't need any optimizations here - we can update the whole tree each time the system font size is changed.
Tested in RN Tester and Expo Go (with the
enableFontScaleChangesUpdatingLayoutfeature flag enabled)Closes #53286
Changelog:
[IOS] [FIXED] - Fixed updating layout in Fabric when the system text multiplier is updated
Test Plan:
Reproduce the error on iOS:
Failing.on.iOS.mp4
Expected output (output after this fix)
Fixed.on.iOS.mp4