Material-ui: [TextField] InputAdornment shouldn't wrap

Created on 7 Apr 2019  路  8Comments  路  Source: mui-org/material-ui


start and end input adormants wraps long lines

  • [x] This is not a v0.x issue.
  • [x] 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. | |

TextField enhancement good first issue

Most helpful comment

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

All 8 comments

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

my case is ",000 Rp" after price

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

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.

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

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

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TimoRuetten picture TimoRuetten  路  3Comments

rbozan picture rbozan  路  3Comments

mattmiddlesworth picture mattmiddlesworth  路  3Comments

sys13 picture sys13  路  3Comments

finaiized picture finaiized  路  3Comments