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

[TextField] Increase shrunk label width to match 100% input width #11215

Merged
merged 1 commit into from
May 3, 2018

Conversation

pandaiolo
Copy link
Contributor

@pandaiolo pandaiolo commented May 2, 2018

Description of issue

Input label is shrunk using CSS scale. The 100% default width of that label makes it smaller than full input width.

Solution in this PR

Increasing accordingly the shrunk input label width let it occupy as much space as possible,
avoiding in some case the wrapping of text (which is very inelegant in this component).

Side effects / misc

The width being increased, it means there is an inconsistency between unshrunk label unwrapped text capacity, and the shrunk one. It means that some text that is not wrapping when shrunk, would wrap when label is not shrunk.

I think that side effect is less problematic than the gain of this PR.

For example, many time the label is used in different ways when user started typing (hence in a shrunk state) : error state, display total of a sum, display additional information. Hence the benefit from having more space in this area - at least up to the parent input 100% width.

@@ -24,6 +24,7 @@ export const styles = theme => ({
shrink: {
transform: 'translate(0, 1.5px) scale(0.75)',
transformOrigin: 'top left',
width: `${100 * 4 / 3}%`,
Copy link
Member

Choose a reason for hiding this comment

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

width: '133%' so the generated CSS isn't a "mess"

@oliviertassinari
Copy link
Member

@pandaiolo Hmmm, why not. I have no idea if it's a good or a bad move. I'm fine trying this change out to discover it.

@oliviertassinari oliviertassinari added the component: text field This is the name of the generic UI component, not the React module! label May 2, 2018
Input label is shrunk using CSS `scale`. The 100% default width is
becoming smaller than full input width. Increasing accordingly the
shrunk input label `width` let it occupy as much space as possible,
avoiding in some case the wrapping of text, which is very inelegant in
this component.
@oliviertassinari oliviertassinari added the new feature New feature or request label May 2, 2018
@oliviertassinari oliviertassinari force-pushed the input-label-shrink-width branch from 232f0a9 to 7a2c903 Compare May 2, 2018 20:25
@oliviertassinari oliviertassinari changed the title Increase shrunk label width to match 100% input width [TextField] Increase shrunk label width to match 100% input width May 2, 2018
@mbrookes
Copy link
Member

mbrookes commented May 2, 2018

"Your PR is important to us. Please hold."

Any chance of a before / after screenshot so the lazy bums amongst us can follow what changes?

@pandaiolo
Copy link
Contributor Author

@mbrookes @oliviertassinari here are some screenshots, you can play with example here https://codesandbox.io/s/n9wy1680nl

Base component, state focused:
screen shot 2018-05-03 at 09 21 18

With some text, the label displays the number of characters, but given the width of the label, this forces the text to wrap:

screen shot 2018-05-03 at 09 21 28

With label element highlighted, smaller width is clear:

screen shot 2018-05-03 at 09 22 23

Given the fact it's scaled down, we can increase width to match component width and avoid wrap / give more room to label-with-input-value:

screen shot 2018-05-03 at 09 21 53

With label element highlighted:

screen shot 2018-05-03 at 09 22 07

@mbrookes
Copy link
Member

mbrookes commented May 3, 2018

Got it - makes perfect sense now.

@mbrookes mbrookes merged commit 8101150 into mui:v1-beta May 3, 2018
oliviertassinari pushed a commit that referenced this pull request May 9, 2018
* Added styles to move input labels to text left align and fixed dialog flicker but when animating width

* Added trailing comma

* revert #11215
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: text field This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants