Skip to content

Conversation

@alexcarpenter
Copy link
Member

@alexcarpenter alexcarpenter commented May 12, 2025

Description

Ensure drawer animation respects RTL usage.

Screen.Recording.2025-05-12.at.10.58.44.AM.mov

To test in the sanbox, add dir="rtl" to the html element within the template.html file.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot
Copy link

changeset-bot bot commented May 12, 2025

🦋 Changeset detected

Latest commit: 9f859df

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented May 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 13, 2025 2:00pm

@alexcarpenter alexcarpenter marked this pull request as ready for review May 12, 2025 17:08
Copy link
Contributor

@aeliox aeliox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +4 to +19
if (dir === 'rtl') {
return 'rtl';
}

if (dir === 'ltr') {
return 'ltr';
}

if (dir === 'auto' || !dir) {
const computedDirection = window.getComputedStyle(element).direction;
if (computedDirection === 'rtl') {
return 'rtl';
}
}

return 'ltr';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it be simplified to this ?

Suggested change
if (dir === 'rtl') {
return 'rtl';
}
if (dir === 'ltr') {
return 'ltr';
}
if (dir === 'auto' || !dir) {
const computedDirection = window.getComputedStyle(element).direction;
if (computedDirection === 'rtl') {
return 'rtl';
}
}
return 'ltr';
const default = 'ltr'
if (dir === 'auto' || !dir) {
const computedDirection = window.getComputedStyle(element).direction;
return computedDirection || default;
}
return dir || default;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test case why I went with the current approach. I think more explicit/defensive approach is right here, someone could hypothetically apply an invalid dir value as it's just an html attribute.

ce9376f

Comment on lines +27 to +29
if (element) {
return getDirectionFromElement(element);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we always using documen.documentElement inside drawer ?

@alexcarpenter alexcarpenter merged commit 0801b02 into main May 13, 2025
32 checks passed
@alexcarpenter alexcarpenter deleted the alexcarpenter-drawer-rtl branch May 13, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants