Skip to content

Commit ed60971

Browse files
authored
Fix broken focus outline on the Select component (#2173)
* fixes broken focus outline on the Select component * fixes linting issue * adds changeset
1 parent 384ae6b commit ed60971

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.changeset/grumpy-rings-sit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Updates styles for the Select component so that the focus outline is even all the way around.

src/Select.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ export type SelectProps = Omit<
77
'multiple' | 'hasLeadingVisual' | 'hasTrailingVisual' | 'as'
88
>
99

10+
const arrowRightOffset = '4px'
11+
1012
const StyledSelect = styled.select`
1113
appearance: none;
14+
border-radius: inherit;
1215
border: 0;
1316
color: currentColor;
1417
font-size: inherit;
@@ -20,8 +23,13 @@ const StyledSelect = styled.select`
2023
2124
background-color should be 'transparent', but Firefox uses the background-color on
2225
<select> to determine the background color used for the dropdown menu.
26+
27+
2. Adds 1px margins to the <select> so the background color doesn't hide the focus outline created with an inset box-shadow.
2328
*/
2429
background-color: inherit;
30+
margin-top: 1px;
31+
margin-left: 1px;
32+
margin-bottom: 1px;
2533
2634
/* 2. Prevents visible overlap of partially transparent background colors.
2735
@@ -50,7 +58,7 @@ const ArrowIndicatorSVG: React.FC<{className?: string}> = ({className}) => (
5058
const ArrowIndicator = styled(ArrowIndicatorSVG)`
5159
pointer-events: none;
5260
position: absolute;
53-
right: 4px;
61+
right: ${arrowRightOffset};
5462
top: 50%;
5563
transform: translateY(-50%);
5664
`

0 commit comments

Comments
 (0)