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

feat(input, textarea): dir is inherited to native form control #30102

Merged
merged 7 commits into from
Mar 11, 2025

Conversation

mehran-prs
Copy link

@mehran-prs mehran-prs commented Dec 25, 2024

Issue number: resolves #30193 resolves #29577


What is the current behavior?

The dir attribute is not inherited by the inner form control. Developers need control over this attribute to provide important context to users, such as text direction.

What is the new behavior?

The dir attribute is a global attribute, so adding it as a property can cause issues. However, developers can still set it as an attribute, and it will be inherited by the native form control element. We also watch it, so any changes to the attribute will be inherited by the native form control.

Does this introduce a breaking change?

  • Yes
  • No

@mehran-prs mehran-prs requested a review from a team as a code owner December 25, 2024 08:26
Copy link

vercel bot commented Dec 25, 2024

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

Name Status Preview Comments Updated (UTC)
ionic-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 11, 2025 9:22pm

@mehran-prs
Copy link
Author

@brandyscarney could you please review this PR?

@brandyscarney
Copy link
Member

Hey @mehran-prs, thank you for the PR! Is there an associated issue that this resolves or a code example where I can see what it fixes?

@mehran-prs
Copy link
Author

Hey @brandyscarney, Thanks for your reply.
Sure, it fixes the cursor position when you type in RTL languages on phones (tested on iPhone)
Let's say you have a native textarea without dir attribute (which its default will be ltr):

      <textarea></textarea>

when you type using RTL characters, your cursor position remains at the beginning (because of the default LTR value, it knows that the cursor should be at the right side of the text, but in RTL languages, it's wrong and should be at the left side):
IMG_4414

We can fix it using dir attribute on it:

 <textarea dir="auto"></textarea>

Result:

IMG_4415

@mehran-prs
Copy link
Author

@brandyscarney could you please check my answer

@mehran-prs
Copy link
Author

@brandyscarney

@thetaPC thetaPC changed the base branch from main to feature-8.5 March 11, 2025 20:17
@thetaPC thetaPC changed the title feat: add 'dir' as an inherited attribute to textarea feat(input, textarea): dir is inherited to native form control Mar 11, 2025
Copy link
Member

@brandyscarney brandyscarney left a comment

Choose a reason for hiding this comment

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

Tested this using the following code and confirmed it is changing the text direction properly now:

<ion-input dir="auto" value="דת מיזמי בדפים משחקים."></ion-input>
<ion-input dir="rtl" value="דת מיזמי בדפים משחקים."></ion-input>
<ion-input dir="auto" value="This is a input"></ion-input>

<ion-textarea dir="auto" value="דת מיזמי בדפים משחקים."></ion-textarea>
<ion-textarea dir="rtl" value="דת מיזמי בדפים משחקים."></ion-textarea>
<ion-textarea dir="auto" value="This is a textarea"></ion-textarea>

Thank you for the PR @mehran-prs!

@thetaPC thetaPC merged commit 504fb6a into ionic-team:feature-8.5 Mar 11, 2025
49 checks passed
@thetaPC
Copy link
Contributor

thetaPC commented Mar 11, 2025

@mehran-prs Congrats for your first PR with us! This feature will be released soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants