Material-ui: maxlength attribute is not working in v1

Created on 15 Aug 2017  路  7Comments  路  Source: mui-org/material-ui

I am trying to limit the maxlength of text type input field to specific number but it's not working.

Here is what I am trying

<TextField
        InputProps={{ placeholder: '#'}}
        type='text'
        value = { _some state_ }
        onChange = { _someFunction_ }) }
        maxLength = "1"
/>

Versions

  • Material-UI: 1.0.0-beta.3
  • React: 15.6.1
  • Browser: chrome
TextField question

Most helpful comment

The maxLength property isn't forwarded to the input element. You can use the inputProps property for that.

All 7 comments

The maxLength property isn't forwarded to the input element. You can use the inputProps property for that.

Is there a reason why TextField can't have the maxLength prop and forward it to the input component? @oliviertassinari

@albinekb There is an endless list of property to forward. TextField is a simple API sugar. The abstraction is meant to leak.

Ok 馃憤 thanks for clarifying. I think this should be written in the docs too! (just to make it clear)

@albinekb Good idea, on it 馃憤

BTW: Are you guys chatting somewhere in some Slack where I can join? I would like to start contributing to this project (as I'm using & enjoying it more and more every day 鉂わ笍 )

or do you have any straight up issues you want me to attempt a PR on? 馃檶
@oliviertassinari

@albinekb You can reach us on gitter :). I have been keeping a list of issues with a good first issue tag. Depends on how much you are aware of the internals of the project, this is a good starting point.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sys13 picture sys13  路  3Comments

anthony-dandrea picture anthony-dandrea  路  3Comments

revskill10 picture revskill10  路  3Comments

finaiized picture finaiized  路  3Comments

chris-hinds picture chris-hinds  路  3Comments