Skip to content

[good first issue] Force LTR direction on the TWD sidebar for RTL-aware apps #225

@kevinccbsg

Description

@kevinccbsg

In apps that set direction: rtl on <html> or <body> (Arabic, Hebrew, and other RTL-aware layouts), the TWD sidebar inherits it and flips — buttons, icons, stats row and the close/open affordance all end up mirrored. Since the sidebar is an overlay tool (not part of the app's localized UI), it should always render left-to-right regardless of the host document direction.

One line fixes it for every RTL-aware app that consumes the library.

Scope

  • In src/ui/utils/styles.ts, add direction: ltr; to the existing .twd-sidebar rule (around line 77, inside the CSS_STYLES template — this is the twd-styles block injected at runtime).
  • Update the existing styles unit test in src/tests/ui/utils/styles.spec.ts to assert the rule is present (the file already checks for .twd-sidebar — extend it to also check the new declaration).
  • Add a short note in docs/ about the sidebar always rendering LTR (one sentence is enough — find the closest existing page about the sidebar UI).

Reference

  • .twd-sidebar rule: src/ui/utils/styles.ts:77
  • Style injection id: src/ui/utils/styles.ts:236 (twd-styles)
  • Existing style test: src/tests/ui/utils/styles.spec.ts

How to reproduce

In examples/twd-test-app/index.html, temporarily add dir=\"rtl\" to the <html> tag and run npm run dev. The sidebar renders mirrored. After the fix, it should stay LTR while the rest of the page flips.

Acceptance criteria

  • .twd-sidebar rule in src/ui/utils/styles.ts includes direction: ltr;.
  • npm run test:ci is green.
  • Sidebar renders correctly (unmirrored) in the test app when <html dir=\"rtl\"> is set.
  • PR includes before / after screenshots of the sidebar in an RTL document.

How to contribute

Read CONTRIBUTING.md first. Quick steps for this issue:

  1. Fork, clone, create a feature branch: git checkout -b fix/sidebar-force-ltr.
  2. From the repo root, build the library and sync it to the example apps:
    npm install
    npm run build
    npm run copy:mock-sw
  3. Install and run the test app:
    cd examples/twd-test-app
    npm install
    npm run dev
  4. Temporarily set <html dir=\"rtl\"> in examples/twd-test-app/index.html to reproduce the issue, then verify the fix.
  5. Run the library's unit tests from the repo root: npm run test:ci.
  6. Open the PR with before / after screenshots.

Tiny surface area, high impact for i18n users — perfect first contribution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions