Skip to content

Commit

Permalink
[TextField] Fix width issue
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Feb 9, 2017
1 parent ca222be commit 8ce1749
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
6 changes: 4 additions & 2 deletions src/Input/Input.js
Expand Up @@ -13,7 +13,8 @@ function isDirty(obj) {
export const styleSheet = createStyleSheet('Input', (theme) => {
return {
wrapper: {
display: 'flex',
// Mimics the default input display property used by browsers for an input.
display: 'inline-block',
position: 'relative',
},
formControl: {
Expand All @@ -29,7 +30,7 @@ export const styleSheet = createStyleSheet('Input', (theme) => {
content: '""',
height: 2,
position: 'absolute',
width: '100%',
right: 0,
transform: 'scaleX(0)',
transition: theme.transitions.create(
'transform',
Expand Down Expand Up @@ -60,6 +61,7 @@ export const styleSheet = createStyleSheet('Input', (theme) => {
lineHeight: 1,
appearance: 'textfield', // Improve type search style.
color: theme.palette.text.primary,
width: '100%',
'&:focus': {
outline: 0,
},
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 33 additions & 22 deletions test/regressions/site/src/tests/Input/Inputs.js
@@ -1,6 +1,7 @@
// @flow weak

import React, { Component } from 'react';
import classNames from 'classnames';
import { createStyleSheet } from 'jss-theme-reactor';
import customPropTypes from 'material-ui/utils/customPropTypes';
import Input from 'material-ui/Input/Input';
Expand All @@ -9,10 +10,14 @@ const styleSheet = createStyleSheet('Inputs', () => ({
container: {
display: 'flex',
flexDirection: 'column',
width: 200,
},
input: {
margin: 10,
},
large: {
width: 300,
},
}));

export default class Inputs extends Component {
Expand All @@ -30,29 +35,35 @@ export default class Inputs extends Component {
const classes = this.context.styleManager.render(styleSheet);

return (
<div className={classes.container}>
<Input
defaultValue="Hello world"
className={classes.input}
/>
<Input
placeholder="Placeholder"
className={classes.input}
/>
<Input
value="Disabled"
className={classes.input}
disabled
/>
<Input
error
value="Error"
className={classes.input}
/>
<div>
<div className={classes.container}>
<Input
value="Hello world"
className={classes.input}
/>
<Input
placeholder="Placeholder"
className={classes.input}
/>
<Input
value="Disabled"
className={classes.input}
disabled
/>
<Input
error
value="Error"
className={classes.input}
/>
<Input
value="Focused"
ref={(c) => { this.focusInput = c; }}
className={classes.input}
/>
</div>
<Input
value="Focused"
ref={(c) => { this.focusInput = c; }}
className={classes.input}
value="Large input"
className={classNames(classes.input, classes.large)}
/>
</div>
);
Expand Down

0 comments on commit 8ce1749

Please sign in to comment.