From b628d4f5d55e78892f145c95dc83de70b20f3753 Mon Sep 17 00:00:00 2001 From: Jiayan Zhuang Date: Mon, 10 Aug 2020 17:52:30 -0700 Subject: [PATCH] Fix the frame issue for truncated text Summary: Changelog: [Internal] - Fix the frame issue for truncated text. When double tapping to expand/truncate the text, the rect of the element always moves to the top and then come back to the original place.. This seems because after truncating/expanding the text, the view would re-render and the container would be destroyed. I used the API accessibilityFrameInContainerSpace to set the frame before. And the frame was not updated properly. Converting the bound to the screen coordinates and set accessibilityFrame directly fixed it. Reviewed By: PeteTheHeat Differential Revision: D23040295 fbshipit-source-id: 1b449c39c79007d5321ff7b565c170f6d3fab8a4 --- .../Text/RCTParagraphComponentAccessibilityProvider.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.mm b/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.mm index 379a4459ca0..fc40be86ace 100644 --- a/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.mm +++ b/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.mm @@ -65,7 +65,7 @@ using namespace facebook::react; firstElement.isAccessibilityElement = YES; firstElement.accessibilityTraits = UIAccessibilityTraitStaticText; firstElement.accessibilityLabel = accessibilityLabel; - firstElement.accessibilityFrameInContainerSpace = _view.bounds; + firstElement.accessibilityFrame = UIAccessibilityConvertFrameToScreenCoordinates(_view.bounds, _view); [firstElement setAccessibilityActivationPoint:CGPointMake( firstElement.accessibilityFrame.origin.x + 1.0, firstElement.accessibilityFrame.origin.y + 1.0)]; @@ -98,7 +98,8 @@ using namespace facebook::react; numberOfButtons++; } element.accessibilityLabel = fragmentText; - element.accessibilityFrameInContainerSpace = fragmentRect; + element.accessibilityFrame = + UIAccessibilityConvertFrameToScreenCoordinates(fragmentRect, self->_view); [elements addObject:element]; }];