Skip to content
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

Inconsistent RTL text display in dropdown field #8645

Open
1 task done
mikeharv opened this issue Nov 4, 2024 · 1 comment
Open
1 task done

Inconsistent RTL text display in dropdown field #8645

mikeharv opened this issue Nov 4, 2024 · 1 comment
Labels
issue: bug Describes why the code or behaviour is wrong

Comments

@mikeharv
Copy link
Contributor

mikeharv commented Nov 4, 2024

Check for duplicates

  • I have searched for similar issues before opening a new one.

Description

When displaying right-to-left (RTL) text in dropdown fields, Blockly currently uses the Right-to-Left Mark (RLM, U+200F) to suggest RTL directionality. However, this approach leads to inconsistent RTL alignment, as the RLM only hints at RTL layout rather than enforcing it across the entire text.

We found that using the Right-to-Left Override (RLO, U+202E) followed by Pop Directional Formatting (PDF, U+202C) produces a more consistent RTL display by enforcing RTL direction for the entire text. The PDF resets the directional formatting after the text, keeping the override localized to the specific field.

Replacing RLM with RLO+PDF ensures the full text displays in a coherent RTL layout, improving readability and alignment when the container is not styled for RTL. We've made that fix in our field override here: code-dot-org/code-dot-org@f73cc95

This bug feels similar to one affecting number fields that was reported several years ago: #1802

Reproduction steps

  1. From the RTL Blockly Playground, open the Logic toolbox category and drag a true block to the workspace.
  2. Using the console, add an option to the dropdown that includes a mix of RTL characters and Latin characters (e.g.) numbers. For example: Blockly.getSelected().getField('BOOL').menuGenerator_.push(["1 תיבה", "TEXT"]).
  3. Observe the inconsistency between the text in the dropdown menu (an RTL element) and the block field (an LTR element).

Stack trace

No response

Screenshots

Image

Browsers

No response

@mikeharv mikeharv added issue: bug Describes why the code or behaviour is wrong issue: triage Issues awaiting triage by a Blockly team member labels Nov 4, 2024
@rachel-fenichel
Copy link
Collaborator

RLO + PDF sounds good to me--thanks for the explanation of the change. We will accept an upstream PR fixing this, if you file one.

It sounds like you have tested this in RTL, particularly with Arabic. Do you know if this changes anything for the math examples given in #1802?

@cpcallen cpcallen removed the issue: triage Issues awaiting triage by a Blockly team member label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Describes why the code or behaviour is wrong
Projects
None yet
Development

No branches or pull requests

3 participants