Skip to content

Commit aebe2e1

Browse files
authored
Focus highlight partly hidden by search close button (#11)
* Don't highlight focus with inset box-shadow It conflicts with close button within search element * Take into account strokeWidth for focus stroke width * Use outline color for button in forced color mode * Update snapshots Not using inset shadow avoid the line in webkit
1 parent b7525c8 commit aebe2e1

11 files changed

+17
-23
lines changed

packages/components/src/button/button.styles.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ const BaseButtonStyles = css`
198198
:host([href]) .control:${focusVisible} {
199199
forced-color-adjust: none;
200200
background: ${SystemColors.ButtonFace};
201-
border-color: ${SystemColors.LinkText};
202-
box-shadow: 0 0 0 1px ${SystemColors.LinkText} inset;
201+
outline-color: ${SystemColors.LinkText};
203202
color: ${SystemColors.LinkText};
204203
fill: currentColor;
205204
}
@@ -263,9 +262,7 @@ const AccentButtonStyles = css`
263262
}
264263
265264
:host([appearance="accent"][href]) .control:${focusVisible} {
266-
border-color: ${SystemColors.LinkText};
267-
box-shadow: 0 0 0 calc(${focusStrokeWidth} * 1px)
268-
${SystemColors.HighlightText} inset;
265+
outline-color: ${SystemColors.HighlightText};
269266
}
270267
`
271268
)
@@ -327,9 +324,7 @@ const ErrorButtonStyles = css`
327324
}
328325
329326
:host([appearance="error"][href]) .control:${focusVisible} {
330-
border-color: ${SystemColors.LinkText};
331-
box-shadow: 0 0 0 calc(${focusStrokeWidth} * 1px)
332-
${SystemColors.HighlightText} inset;
327+
outline-color: ${SystemColors.HighlightText};
333328
}
334329
`
335330
)
@@ -466,8 +461,7 @@ const OutlineButtonStyles = css`
466461
:host([appearance="outline"][href]) .control:hover,
467462
:host([appearance="outline"][href]) .control:${focusVisible} {
468463
forced-color-adjust: none;
469-
border-color: ${SystemColors.LinkText};
470-
box-shadow: 0 0 0 1px ${SystemColors.LinkText} inset;
464+
outline-color: ${SystemColors.LinkText};
471465
}
472466
`
473467
)
@@ -512,8 +506,7 @@ const StealthButtonStyles = css`
512506
}
513507
514508
:host([appearance="stealth"]:${focusVisible}) .control {
515-
background: ${SystemColors.Highlight};
516-
box-shadow: 0 0 0 1px ${SystemColors.Highlight};
509+
outline-color: ${SystemColors.Highlight};
517510
color: ${SystemColors.HighlightText};
518511
fill: currentColor;
519512
}
@@ -523,7 +516,7 @@ const StealthButtonStyles = css`
523516
}
524517
525518
:host([appearance="stealth"][href]:hover) .control,
526-
:host([appearance="stealth"][href]:${focusVisible}) .control {
519+
:host([appearance="stealth"][href]:${focusVisible}) .control {
527520
background: ${SystemColors.LinkText};
528521
border-color: ${SystemColors.LinkText};
529522
color: ${SystemColors.HighlightText};

packages/components/src/search/search.styles.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ export const searchStyles: FoundationElementTemplate<
158158
159159
:host(:focus-within:not([disabled])) .root {
160160
border-color: ${accentFillFocus};
161-
box-shadow: 0 0 0 calc((${focusStrokeWidth} - 1) * 1px) ${accentFillFocus}
162-
inset;
161+
box-shadow: 0 0 0 calc((${focusStrokeWidth} - ${strokeWidth}) * 1px)
162+
${accentFillFocus};
163163
}
164164
165165
.clear-button__hidden {
@@ -229,7 +229,8 @@ export const searchStyles: FoundationElementTemplate<
229229
}
230230
:host(:focus-within:enabled) .root {
231231
border-color: ${SystemColors.Highlight};
232-
box-shadow: 0 0 0 1px ${SystemColors.Highlight} inset;
232+
box-shadow: 0 0 0 calc((${focusStrokeWidth} - ${strokeWidth}) * 1px)
233+
${SystemColors.Highlight};
233234
}
234235
input::placeholder {
235236
color: ${SystemColors.GrayText};
-10 Bytes
Loading
-18 Bytes
Loading
-153 Bytes
Loading

packages/components/src/select/select.styles.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import {
66
accentFillActive,
77
accentFillFocus,
8-
accentFillHover,
98
bodyFont,
109
controlCornerRadius,
1110
designUnit,
@@ -110,8 +109,8 @@ export const selectStyles: FoundationElementTemplate<
110109
111110
:host(:${focusVisible}) {
112111
border-color: ${accentFillFocus};
113-
box-shadow: 0 0 0 calc((${focusStrokeWidth} - 1) * 1px) ${accentFillFocus}
114-
inset;
112+
box-shadow: 0 0 0 calc((${focusStrokeWidth} - ${strokeWidth}) * 1px)
113+
${accentFillFocus};
115114
}
116115
117116
:host([disabled]) {
@@ -250,7 +249,7 @@ export const selectStyles: FoundationElementTemplate<
250249
:host(:${focusVisible}) ::slotted([aria-selected="true"][role="option"]:not([disabled])) {
251250
background: ${SystemColors.Highlight};
252251
border-color: ${SystemColors.ButtonText};
253-
box-shadow: 0 0 0 calc(${focusStrokeWidth} * 1px) inset
252+
box-shadow: 0 0 0 calc((${focusStrokeWidth} - ${strokeWidth}) * 1px)
254253
${SystemColors.HighlightText};
255254
color: ${SystemColors.HighlightText};
256255
fill: currentcolor;

packages/components/src/text-field/text-field.styles.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ export const textFieldStyles: FoundationElementTemplate<
131131
132132
:host(:focus-within:not([disabled])) .root {
133133
border-color: ${accentFillFocus};
134-
box-shadow: 0 0 0 calc((${focusStrokeWidth} - 1) * 1px) ${accentFillFocus}
135-
inset;
134+
box-shadow: 0 0 0 calc((${focusStrokeWidth} - ${strokeWidth}) * 1px)
135+
${accentFillFocus};
136136
}
137137
138138
:host([appearance='filled']) .root {
@@ -186,7 +186,8 @@ export const textFieldStyles: FoundationElementTemplate<
186186
}
187187
:host(:focus-within:enabled) .root {
188188
border-color: ${SystemColors.Highlight};
189-
box-shadow: 0 0 0 1px ${SystemColors.Highlight} inset;
189+
box-shadow: 0 0 0 calc((${focusStrokeWidth} - ${strokeWidth}) * 1px)
190+
${SystemColors.Highlight};
190191
}
191192
input::placeholder {
192193
color: ${SystemColors.GrayText};
-24 Bytes
Loading
0 Bytes
Loading
-137 Bytes
Loading

0 commit comments

Comments
 (0)