[fix] Layout of nested Text elements

Remove the 'dir=auto' attribute from nested Text elements as this can cause
browsers to produce broken text layouts.

Fix #1714
This commit is contained in:
Nicolas Gallagher
2020-08-25 11:00:27 -07:00
parent a31c4c65d0
commit 9a0acc5464
2 changed files with 5 additions and 3 deletions
@@ -22,7 +22,6 @@ exports[`components/Text nested 1`] = `
<span
class="css-text-901oao css-textHasAncestor-16my406"
data-testid="child"
dir="auto"
/>
</div>
`;
+5 -2
View File
@@ -153,8 +153,11 @@ const Text = forwardRef<TextProps, *>((props, forwardedRef) => {
const component = hasTextAncestor ? 'span' : 'div';
const supportedProps = pickProps(props);
supportedProps.classList = classList;
// 'auto' by default allows browsers to infer writing direction
supportedProps.dir = dir !== undefined ? dir : 'auto';
supportedProps.dir = dir;
// 'auto' by default allows browsers to infer writing direction (root elements only)
if (!hasTextAncestor) {
supportedProps.dir = dir != null ? dir : 'auto';
}
supportedProps.onClick = handleClick;
supportedProps.ref = setRef;
supportedProps.style = style;