Skip to content

Commit cbcb290

Browse files
authored
Merge pull request #1740 from Shopify/textfield-icon-position-2
[Textfield] Adjusting padding when there's a Prefix or Suffix
2 parents f237493 + eced110 commit cbcb290

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ The format is based on [these versioning and changelog guidelines][changelog-gui
1010

1111
- Changed Form to submit a form by default when the Enter key is pressed, and added the prop `implicitSubmit` to disable this default ([#1630](https://github.com/Shopify/polaris-react/pull/1630))
1212

13+
### Bug fixes
14+
15+
- Fixed text field padding when a prefix or suffix is included ([#1740](https://github.com/Shopify/polaris-react/pull/1740))
16+
1317
## 2.3.1 - 2018-07-05
1418

1519
### Enhancements

src/components/TextField/TextField.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ $stacking-order: (
9797
font-weight: inherit;
9898
appearance: none;
9999

100+
.Prefix + & {
101+
padding-left: 0;
102+
}
103+
100104
&:disabled {
101105
background: none;
102106
border: border(transparent);
@@ -127,6 +131,10 @@ $stacking-order: (
127131
}
128132
}
129133

134+
.Input-suffixed {
135+
padding-right: 0;
136+
}
137+
130138
.Backdrop {
131139
position: absolute;
132140
z-index: z-index(backdrop, $stacking-order);

src/components/TextField/TextField.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ export default class TextField extends React.PureComponent<Props, State> {
224224
labelledBy.push(`${id}Suffix`);
225225
}
226226

227+
const inputClassName = classNames(
228+
styles.Input,
229+
suffix && styles['Input-suffixed'],
230+
);
231+
227232
const input = React.createElement(multiline ? 'textarea' : 'input', {
228233
name,
229234
id,
@@ -236,7 +241,7 @@ export default class TextField extends React.PureComponent<Props, State> {
236241
onBlur,
237242
style,
238243
autoComplete: normalizeAutoComplete(autoComplete),
239-
className: styles.Input,
244+
className: inputClassName,
240245
onChange: this.handleChange,
241246
ref: this.setInput,
242247
min,

0 commit comments

Comments
 (0)