-
Notifications
You must be signed in to change notification settings - Fork 887
[PM-20026] RTL text direction #5012
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
base: main
Are you sure you want to change the base?
Conversation
Thank you for your contribution! We've added this to our internal Community PR board for review. |
Note that there is still a problem with bi-directional text in the password history view. Historic custom hidden passwords are not formatted properly. See the following screenshot: (Password is 1234 5678 in both cases, only field label has been changed. Current behavior is the one to the left.) Upon some digging I've found this to be the root cause. Possible solution:
I could not figure out how to add a Alternatively, |
@david-livefront @brian-livefront Could you please review the proposed changes? Thank you |
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.
🤔 I'm wondering if having a BidiTextManager
and ProvidableCopositionLocal<BidiTextManager>
would be a better way to handle formatting. Something along the lines of
interface BidiTextManager {
fun unicodeWrap(text: String): String
}
val LocalBidiTextManager: ProvidableCompositionLocal<BidiTextManager> = compositionLocalOf {
error("CompositionLocal BidiTextManager not present")
}
Then we can apply the formatting in our common Composables.
An example from BitwardenTextField
would look like...
fun BitwardenTextField(...) {
var textFieldValueState by remember { mutableStateOf(TextFieldValue(text = formattedText)) }
val textFieldValue = textFieldVauleState.copy(
text = LocalBidiTextManager.current.unicodeWrap(value),
)
// Remaining logic omitted...
}
With that approach I was able to achieve the following results

textAlign = if (LocalLayoutDirection.current == LayoutDirection.Rtl) { | ||
TextAlign.Left | ||
} else { | ||
TextAlign.Right | ||
}, |
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.
We should avoid manually setting the text alignment in screens like this.
We also do not want to use Left
and Right
alignments. We should be using Start
and End
so they respect the selected language's layout direction.
sensitiveInfoMedium = sensitiveInfoMedium.copy(textAlign = newTextAlign), | ||
eyebrowMedium = eyebrowMedium.copy(textAlign = newTextAlign), | ||
) | ||
} |
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.
All files must end with a newline.
The Setup section of README has instructions on how to create a macro to enforce this and other Code style guidelines.
@@ -133,7 +132,6 @@ private fun EnterpriseSignOnScreenContent( | |||
Spacer(modifier = Modifier.height(height = 12.dp)) | |||
Text( | |||
text = stringResource(id = R.string.log_in_sso_summary), | |||
textAlign = TextAlign.Start, |
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.
We should not be removing alignment assignments in the screens. Start
and End
will respect the layout direction of the selected language.
@@ -228,6 +245,7 @@ val bitwardenTypography: BitwardenTypography = BitwardenTypography( | |||
trim = LineHeightStyle.Trim.None, | |||
), | |||
platformStyle = PlatformTextStyle(includeFontPadding = false), | |||
textDirection = TextDirection.Ltr, |
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.
Should this be using TextDirection.Content
?
@@ -240,6 +258,7 @@ val bitwardenTypography: BitwardenTypography = BitwardenTypography( | |||
trim = LineHeightStyle.Trim.None, | |||
), | |||
platformStyle = PlatformTextStyle(includeFontPadding = false), | |||
textDirection = TextDirection.Ltr, |
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.
Should this be using TextDirection.Content
?
Can you update your fork & branches? There are several conflicts since we've moved common logic and UI components to their own module. |
🎟️ Tracking
#4753
📔 Objective
Fixing text direction of LTR text in RTL layout, and vice versa.
📸 Screenshots
(see "Steps To Reproduce" in the tracked issue)
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes