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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TextField] InputAdornment shouldn't wrap #15240

Closed
2 tasks done
TrejGun opened this issue Apr 7, 2019 · 8 comments 路 Fixed by #18641
Closed
2 tasks done

[TextField] InputAdornment shouldn't wrap #15240

TrejGun opened this issue Apr 7, 2019 · 8 comments 路 Fixed by #18641
Labels
component: text field This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. new feature New feature or request

Comments

@TrejGun
Copy link
Contributor

TrejGun commented Apr 7, 2019

start and end input adormants wraps long lines

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 馃

start and end input adormants should not wraps long lines

Current Behavior 馃槸

long lines are wrapped
Screen Shot 2019-04-07 at 7 10 24 PM

Steps to Reproduce 馃暪

      <TextField
        margin="dense"
        type="number"
        name="price"
        InputProps={{
          startAdornment: <InputAdornment position="start">blah blah</InputAdornment>,
          endAdornment: <InputAdornment position="end">blah blah</InputAdornment>,
        }}
      />

Possible solution

add

whiteSpace: "nowrap"

Screen Shot 2019-04-07 at 7 14 15 PM

Context 馃敠

Your Environment 馃寧

Tech Version
Material-UI v3.9.2
React 16.8.2
Browser chrome
TypeScript -
etc.
@eps1lon eps1lon added component: text field This is the name of the generic UI component, not the React module! new feature New feature or request labels Apr 7, 2019
@eps1lon
Copy link
Member

eps1lon commented Apr 7, 2019

Could you provide a concrete example? I don't think we should support adding "blah blah" as adornments out of the box 馃槈

@TrejGun
Copy link
Contributor Author

TrejGun commented Apr 7, 2019

my case is ",000 Rp" after price

@olistic
Copy link

olistic commented Apr 29, 2019

Hi @eps1lon, I take from your comment that there's a limitation on the length of the adornments?

I have the following use case:

Screen Shot 2019-04-29 at 01 09 43

@eps1lon
Copy link
Member

eps1lon commented Apr 29, 2019

They are really just intended for little adornments. You can probably change the styling to increase the width.

Have you tried using helperText instead? Sounds more appropriate.

The spec has a different solution for units in the form of start/end icons. We can look into implementing those.

@olistic
Copy link

olistic commented Apr 29, 2019

Thanks for your suggestions. Overriding the InputAdornment's root CSS with white-space: nowrap; did the trick for me.

@TrejGun
Copy link
Contributor Author

TrejGun commented May 21, 2019

on this page google uses pretty long adorment "@gmail.com"
https://material.io/design/components/text-fields.html#filled-text-field

@oliviertassinari oliviertassinari added the good first issue Great for first contributions. Enable to learn the contribution process. label Nov 30, 2019
@oliviertassinari
Copy link
Member

It seems that Bootstrap uses the same approach with the prepend: https://getbootstrap.com/docs/4.4/components/forms/#inline-forms.

I think that we can move forward with the proposed fix:

diff --git a/packages/material-ui/src/InputAdornment/InputAdornment.js b/packages/material-ui/src/InputAdornment/InputAdornment.js
index 6c05f8ab9..6c6149270 100644
--- a/packages/material-ui/src/InputAdornment/InputAdornment.js
+++ b/packages/material-ui/src/InputAdornment/InputAdornment.js
@@ -12,6 +12,7 @@ export const styles = {
     height: '0.01em', // Fix IE 11 flexbox alignment. To remove at some point.
     maxHeight: '2em',
     alignItems: 'center',
+    whiteSpace: 'nowrap',
   },
   /* Styles applied to the root element if `variant="filled"`. */
   filled: {

@olistic Do you want to push it further?

@oliviertassinari oliviertassinari changed the title InputAdornment should not wrap [TextField] InputAdornment shouldn't wrap Nov 30, 2019
@TrejGun
Copy link
Contributor Author

TrejGun commented Dec 1, 2019

#18641

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! good first issue Great for first contributions. Enable to learn the contribution process. new feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants