Skip to content

Commit

Permalink
fix(components): Force consistent height of Select across browsers (#444
Browse files Browse the repository at this point in the history
)
  • Loading branch information
connor-baer authored Jul 23, 2019
1 parent bb7c269 commit 9f31e5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import { textMega, disableVisually } from '../../styles/style-helpers';

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

// HACK: Firefox includes the border-width in the overall height of the element
// (despite box-sizing: border-box), so we have to force the height.
// line-height + 2px + (vertical padding * 2) + (border-width * 2)
const MAX_HEIGHT = '42px';

const selectBaseStyles = ({ theme }) => css`
label: select;
appearance: none;
Expand All @@ -40,6 +45,7 @@ const selectBaseStyles = ({ theme }) => css`
color: ${theme.colors.n900};
padding: ${theme.spacings.byte} ${theme.spacings.tera} ${theme.spacings.byte}
${theme.spacings.kilo};
max-height: ${MAX_HEIGHT};
position: relative;
width: 100%;
z-index: ${theme.zIndex.select};
Expand Down
7 changes: 7 additions & 0 deletions src/components/Select/__snapshots__/Select.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ exports[`Select should not render with invalid styles when also passed the disab
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
color: #212933;
padding: 8px 32px 8px 12px;
max-height: 42px;
position: relative;
width: 100%;
z-index: 20;
Expand Down Expand Up @@ -103,6 +104,7 @@ exports[`Select should render with a prefix when passed the prefix prop 1`] = `
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
color: #212933;
padding: 8px 32px 8px 12px;
max-height: 42px;
position: relative;
width: 100%;
z-index: 20;
Expand Down Expand Up @@ -192,6 +194,7 @@ exports[`Select should render with default styles 1`] = `
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
color: #212933;
padding: 8px 32px 8px 12px;
max-height: 42px;
position: relative;
width: 100%;
z-index: 20;
Expand Down Expand Up @@ -265,6 +268,7 @@ exports[`Select should render with disabled styles when passed the disabled prop
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
color: #212933;
padding: 8px 32px 8px 12px;
max-height: 42px;
position: relative;
width: 100%;
z-index: 20;
Expand Down Expand Up @@ -348,6 +352,7 @@ exports[`Select should render with inline styles when passed the inline prop 1`]
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
color: #212933;
padding: 8px 32px 8px 12px;
max-height: 42px;
position: relative;
width: 100%;
z-index: 20;
Expand Down Expand Up @@ -437,6 +442,7 @@ exports[`Select should render with invalid styles when passed the invalid prop 1
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
color: #212933;
padding: 8px 32px 8px 12px;
max-height: 42px;
position: relative;
width: 100%;
z-index: 20;
Expand Down Expand Up @@ -511,6 +517,7 @@ exports[`Select should render with no margin styles when passed the noMargin pro
box-shadow: inset 0 1px 2px 0 rgba(102,113,123,0.12);
color: #212933;
padding: 8px 32px 8px 12px;
max-height: 42px;
position: relative;
width: 100%;
z-index: 20;
Expand Down

0 comments on commit 9f31e5a

Please sign in to comment.