Skip to content

Commit 9f31e5a

Browse files
authored
fix(components): Force consistent height of Select across browsers (#444)
1 parent bb7c269 commit 9f31e5a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/components/Select/Select.js

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ import { textMega, disableVisually } from '../../styles/style-helpers';
2828

2929
import { ReactComponent as ArrowsIcon } from './arrows.svg';
3030

31+
// HACK: Firefox includes the border-width in the overall height of the element
32+
// (despite box-sizing: border-box), so we have to force the height.
33+
// line-height + 2px + (vertical padding * 2) + (border-width * 2)
34+
const MAX_HEIGHT = '42px';
35+
3136
const selectBaseStyles = ({ theme }) => css`
3237
label: select;
3338
appearance: none;
@@ -40,6 +45,7 @@ const selectBaseStyles = ({ theme }) => css`
4045
color: ${theme.colors.n900};
4146
padding: ${theme.spacings.byte} ${theme.spacings.tera} ${theme.spacings.byte}
4247
${theme.spacings.kilo};
48+
max-height: ${MAX_HEIGHT};
4349
position: relative;
4450
width: 100%;
4551
z-index: ${theme.zIndex.select};

src/components/Select/__snapshots__/Select.spec.js.snap

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ exports[`Select should not render with invalid styles when also passed the disab
1313
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
1414
color: #212933;
1515
padding: 8px 32px 8px 12px;
16+
max-height: 42px;
1617
position: relative;
1718
width: 100%;
1819
z-index: 20;
@@ -103,6 +104,7 @@ exports[`Select should render with a prefix when passed the prefix prop 1`] = `
103104
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
104105
color: #212933;
105106
padding: 8px 32px 8px 12px;
107+
max-height: 42px;
106108
position: relative;
107109
width: 100%;
108110
z-index: 20;
@@ -192,6 +194,7 @@ exports[`Select should render with default styles 1`] = `
192194
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
193195
color: #212933;
194196
padding: 8px 32px 8px 12px;
197+
max-height: 42px;
195198
position: relative;
196199
width: 100%;
197200
z-index: 20;
@@ -265,6 +268,7 @@ exports[`Select should render with disabled styles when passed the disabled prop
265268
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
266269
color: #212933;
267270
padding: 8px 32px 8px 12px;
271+
max-height: 42px;
268272
position: relative;
269273
width: 100%;
270274
z-index: 20;
@@ -348,6 +352,7 @@ exports[`Select should render with inline styles when passed the inline prop 1`]
348352
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
349353
color: #212933;
350354
padding: 8px 32px 8px 12px;
355+
max-height: 42px;
351356
position: relative;
352357
width: 100%;
353358
z-index: 20;
@@ -437,6 +442,7 @@ exports[`Select should render with invalid styles when passed the invalid prop 1
437442
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
438443
color: #212933;
439444
padding: 8px 32px 8px 12px;
445+
max-height: 42px;
440446
position: relative;
441447
width: 100%;
442448
z-index: 20;
@@ -511,6 +517,7 @@ exports[`Select should render with no margin styles when passed the noMargin pro
511517
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
512518
color: #212933;
513519
padding: 8px 32px 8px 12px;
520+
max-height: 42px;
514521
position: relative;
515522
width: 100%;
516523
z-index: 20;

0 commit comments

Comments
 (0)