-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
floating label rtl fix #11324
floating label rtl fix #11324
Conversation
add rtl fix to floating label
Thank you for creating a pull request for RTL, its great to see more people helping on that. This is a great change, but it is missing all-platforms support. |
src/components/label/label.md.scss
Outdated
@@ -48,6 +48,12 @@ $label-md-margin: $item-md-padding-top ($item-md-padding-rig | |||
transition: transform 150ms ease-in-out; | |||
} | |||
|
|||
html[dir=rtl] { |
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.
Preferably, use [dir="rtl"]
instead, to give the option to use rtl on any html component
src/components/label/label.md.scss
Outdated
@@ -48,6 +48,12 @@ $label-md-margin: $item-md-padding-top ($item-md-padding-rig | |||
transition: transform 150ms ease-in-out; | |||
} | |||
|
|||
html[dir=rtl] { | |||
.label-md[floating] { |
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.
When it is a single block, preferably, use [dir="rtl"] .label-md[floating]
instead of nesting. (see segment)
problems with transform-origin with both windows and ios platform for rtl and also wrong translate3d for rtl for windows platform
src/components/label/label.wp.scss
Outdated
@@ -56,6 +61,11 @@ $label-wp-text-color-focused: color($colors-wp, primary) !default; | |||
transform: translate3d(0, 0, 0) scale(.8); | |||
} | |||
|
|||
html[dir="rtl"] .input-has-focus .label-wp[floating], |
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.
This rtl behavior is exactly the same as ltr behavior, so no need to write it again (entire block)
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.
actually it's needed as the [dir="rtl"] .label-wp[floating] transform: translate3d will replace the .input-has-focus .label-wp[floating] transform: translate3d on rtl
src/components/label/label.wp.scss
Outdated
@@ -40,6 +40,11 @@ $label-wp-text-color-focused: color($colors-wp, primary) !default; | |||
transform-origin: left top; | |||
} | |||
|
|||
html[dir="rtl"] .label-wp[floating] { | |||
transform: translate3d(-8px, 34px, 0); |
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.
This rtl behavior is exactly the same as ltr behavior, so no need to write it again (this specific line)
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.
The ltr translate 8px to the right, this one translate it to the left (-8px instead of 8px), am I missing something here?
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.
No, I was missing it. Thanks
src/components/label/label.md.scss
Outdated
@@ -48,6 +48,10 @@ $label-md-margin: $item-md-padding-top ($item-md-padding-rig | |||
transition: transform 150ms ease-in-out; | |||
} | |||
|
|||
html[dir="rtl"] .label-md[floating] { | |||
transform-origin: right top; |
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.
Indentation is 4 spaces instead of 2
remove reference of "html", just plain '[dir="rtl"] indent 2 space instead of 4
src/components/label/label.wp.scss
Outdated
@@ -61,8 +61,8 @@ html[dir="rtl"] .label-wp[floating] { | |||
transform: translate3d(0, 0, 0) scale(.8); | |||
} | |||
|
|||
html[dir="rtl"] .input-has-focus .label-wp[floating], | |||
html[dir="rtl"] .input-has-value .label-wp[floating] { | |||
[dir="rtl"] .input-has-focus .label-wp[floating], |
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.
This one still looks the same to me, both for ltr and rtl
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.
because I've added a transform: translate3d
with more specific reference then a class (an attribute) it will replace the original LTR (.input-has-focus or .input-has-value
), with default one so the label won't float on RTL direction, therefore I've added the same thing with attribute specific (dir="rtl"
) ... it's hackish, I know, but couldn't find a better suitable easy way.
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 not sure what you mean...
I am referring to:
.input-has-focus .label-wp[floating],
.input-has-value .label-wp[floating] {
transform: translate3d(0, 0, 0) scale(.8);
}
[dir="rtl"] .input-has-focus .label-wp[floating],
[dir="rtl"] .input-has-value .label-wp[floating] {
transform: translate3d(0, 0, 0) scale(.8);
}
Which as I see it, is equivalent to:
.input-has-focus .label-wp[floating],
.input-has-value .label-wp[floating] {
transform: translate3d(0, 0, 0) scale(.8);
}
Because you override the ltr with the same behavior
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.
Easy,
unfortunately the browser will choose this rule
[dir="rtl"] .label-wp[floating] {
transform: translate3d(-8px, 34px, 0);
}
over this one
.input-has-focus .label-wp[floating],
.input-has-value .label-wp[floating] {
transform: translate3d(0, 0, 0) scale(.8);
}
even if the label has a parent element with input-has-focus
class because of the attribute specification from previous rule which has a higher priority than a class. so I've added exactly the same thing over again with attribute specification, so the browser choose the right one on focus or when the input has value in rtl mode...
This can be easily seen in a test, try to remove those three line code and test a wp platform you'll see the floating label won't float and won't go up on focus.
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.
Hmm.. ok.
I might nor know enough about CSS priorities, but from a small test, it seems like it goes like I said it would: https://codepen.io/anon/pen/BRzxza
As far as I understand, that is because of the order of selectors:
.input-has-focus .label-wp[floating]
is after [dir="rtl"] .label-wp[floating]
and thus takes president.
Let me know if you still think otherwise (as again, I am not completely sure of it)
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.
Yes, you're right, sorry, my bad, my way of testing this was wrong!
remove unnecessary duplicate rule
@manucorporat @brandyscarney This looks done. Can you merge? (and add |
I'm creating another pr which contains this too. |
In theory, PRs should be "Small, independent, complete contributions" such that it is preferable to have 2 different PRs rather than 1 PR with 2 features. If you are interested in learning more -
|
@AmitMY So I should open this and make some new other PR for my other changes? sorry I'm new to this. |
@sijav No problem :) I really recommend that video, it explains a lot about open source PRs and the review process |
Yes, Thanks a lot, |
Add RTL support to Floating labels
Short description of what this resolves:
RTL support for floating labels
Changes proposed in this pull request:
Ionic Version: 2.x / 3.x