-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[TextField] add floatingLabelFocusStyle prop #4043
[TextField] add floatingLabelFocusStyle prop #4043
Conversation
|
||
describe('<TextFieldLabel>', () => { | ||
it('uses focus styles', () => { | ||
const component = shallow( |
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.
Can you use wrapper
instead of component
?
Updates made. Let me know if there's anything else! |
@echenley That looks good to me. Could you squash down and rebase? Thanks. |
f28bdf1
to
8904c37
Compare
@oliviertassinari Should be good to go. Thank you! |
* The style object to use to override floating label styles when focused. | ||
*/ | ||
floatingLabelFocusStyle: PropTypes.object, | ||
|
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.
Could you remove this line cf. #4073 😁?
8904c37
to
027c96d
Compare
@nathanmarks Feel free to merge if you are happy with this PR. |
pointerEvents: 'none', | ||
}, props.shrinkStyle) : null; | ||
|
||
return Object.assign({ |
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.
@oliviertassinari should we enforce the styles.root
convention 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.
@nathanmarks I would say yes 👍.
027c96d
to
bd92715
Compare
Updated:
|
cursor: props.disabled ? 'default' : 'text', | ||
transform: 'scale(1) translate3d(0, 0, 0)', | ||
transformOrigin: 'left top', | ||
pointerEvents: 'auto', |
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.
Can we remove pointerEvents: 'none',
out of the TextField.js~getStyles().floatingLabel
object? seems like the default is already enforced here. (here being in the getStyles() function as a whole, not this 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.
Updated.
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.
(do correct me if I'm wrong though!)
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.
You're right, it was redundant. I wonder if it might be better to just move the defaultStyles in TextFieldLabel to styles.floatingLabel in TextField instead of the other way? That would remove one object merge from the mix. I'll make a commit to show what I mean.
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.
See f8a4a63.
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 wonder if it might be better to just move the defaultStyles in TextFieldLabel to styles.floatingLabel in TextField instead of the other way?
The idea is to make each component independent. I think that we shouldn't move the style to the parent component.
bd92715
to
b800fe1
Compare
@oliviertassinari |
The |
@nathanmarks I agree 👍. Let's remove the |
@nathanmarks Humm, I'm not sure though. There is like 10 lines of logic to update the color after behing set. |
@oliviertassinari bleh, that's annoying. |
@echenley Could you remove the second commit? Let's try to keep separate our concerns. |
I guess it just feels strange because it is an escape hatch by design through to the component during the focus state of the input the parent contains (these types of props). |
f8a4a63
to
b800fe1
Compare
Yeah, the only alternative seems to be passing TextField state (or at least |
@echenley yeah, lesser of evils 😄 This is one of those annoying cases too where even JS non-inline styles won't make it cleaner either because the label doesn't actually get focussed when the input does, ah well! |
I've noticed a problem with the label color while checking out this PR in the docs -- not just on this PR but also on HEAD and MUI DocsSpec |
@nathanmarks Strange, I don't see this when I run the docs locally or here: http://www.material-ui.com/v0.15.0-beta.2/#/components/text-field Edit: oh, I see it now. If it's focused and has text, it reverts to the default style. I'll add a fix. |
b800fe1
to
f82b3ac
Compare
if (state.hasValue) { | ||
styles.floatingLabel.color = fade(props.disabled ? disabledTextColor : floatingLabelColor, 0.5); | ||
} | ||
|
||
if (state.isFocused) { | ||
styles.floatingLabel.color = focusColor; | ||
} |
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.
@nathanmarks Switching the order here fixes the focus color issue. Unless I'm missing why hasValue was overriding it.
@echenley Nice PR, thanks👍. |
@echenley Thanks for sorting that bug!!! |
Looks like after 0.15.0-beta.2 (included) this will allow for a dense text field. |
floatingLabelFocusStyle
prop to<TextField>