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
This commit is contained in:
Jiayan Zhuang
2020-08-10 17:54:33 -07:00
committed by Facebook GitHub Bot
parent 4c0d802b4f
commit b628d4f5d5
@@ -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];
}];