Skip to content

Commit 60b44bb

Browse files
authored
fix(picker): rename is-focused class to is-keyboardFocused (#2377)
* fix(picker): rename is-focused to is-keyboardFocused The .is-focused class was being used as if it was .is-keyboardFocused, in combination with :focus-visible in selectors. Rather than removing the class, keep it in its renamed form in order for SWC to still be able to convert it to an attribute and continue testing it via its Storybook control. This fixes an existing issue on the docs site, where if you click the picker twice, the focus indicator ring will appear. This is because the docs site adding the .is-focused class. Updated the existing story that was labeled "Focused" that was showing keyboard focused to use the play function, for Chromatic coverage ref: https://www.chromatic.com/docs/hoverfocus/
1 parent cf44e69 commit 60b44bb

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

components/picker/index.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ governing permissions and limitations under the License.
162162
--highcontrast-picker-background-color: ButtonFace;
163163

164164
&:focus-visible,
165-
&.is-focused {
165+
&.is-keyboardFocused {
166166
--highcontrast-picker-border-color-hover: ButtonText;
167167
}
168168

@@ -265,7 +265,7 @@ governing permissions and limitations under the License.
265265
}
266266

267267
&:focus-visible,
268-
&.is-focused {
268+
&.is-keyboardFocused {
269269
outline: none;
270270
background-color: var(--highcontrast-picker-background-color, var(--mod-picker-background-color-key-focus, var(--spectrum-picker-background-color-key-focus)));
271271
border-color: var(--highcontrast-picker-border-color-default, var(--mod-picker-border-color-key-focus, var(--spectrum-picker-border-color-key-focus)));
@@ -309,7 +309,7 @@ governing permissions and limitations under the License.
309309
}
310310

311311
&:focus-visible,
312-
&.is-focused {
312+
&.is-keyboardFocused {
313313
border-color: var(--highcontrast-picker-border-color-default, var(--mod-picker-border-color-error-key-focus, var(--spectrum-picker-border-color-error-key-focus)));
314314
}
315315
}
@@ -348,7 +348,7 @@ governing permissions and limitations under the License.
348348
color: var(--highcontrast-picker-content-color-default, var(--mod-picker-font-color-default-open, var(--spectrum-picker-font-color-default-open)));
349349
background-color: var(--highcontrast-picker-background-color, var(--mod-picker-background-color-default-open, var(--spectrum-picker-background-color-default-open)));
350350
border-color: var(--highcontrast-picker-border-color-default, var(--mod-picker-border-default-open, var(--spectrum-picker-border-color-default-open)));
351-
351+
352352
&:hover {
353353
color: var(--highcontrast-picker-content-color-default, var(--mod-picker-font-color-hover-open, var(--spectrum-picker-font-color-hover-open)));
354354
background-color: var(--highcontrast-picker-background-color, var(--mod-picker-background-color-hover-open, var(--spectrum-picker-background-color-hover-open)));
@@ -467,7 +467,7 @@ governing permissions and limitations under the License.
467467
}
468468

469469
&:focus-visible,
470-
&.is-focused {
470+
&.is-keyboardFocused {
471471
background-color: var(--highcontrast-picker-background-color, transparent);
472472

473473
/* Focus indicator changes from a ring to a line underneath. */

components/picker/stories/picker.stories.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// Import the component markup template
2-
import { Template } from "./template";
3-
41
import { Default as MenuStories } from "@spectrum-css/menu/stories/menu.stories.js";
2+
import { Template } from "./template";
53

64
export default {
75
title: "Components/Picker",
@@ -64,8 +62,8 @@ export default {
6462
},
6563
control: "boolean",
6664
},
67-
isFocused: {
68-
name: "Focused",
65+
isKeyboardFocused: {
66+
name: "Keyboard focused",
6967
type: { name: "boolean" },
7068
table: {
7169
type: { summary: "boolean" },
@@ -108,9 +106,9 @@ export default {
108106
label: "Country",
109107
placeholder: "Select a country",
110108
isQuiet: false,
109+
isKeyboardFocused: false,
111110
isLoading: false,
112111
isDisabled: false,
113-
isFocused: false,
114112
isInvalid: false,
115113
isOpen: false,
116114
},
@@ -176,9 +174,10 @@ Invalid.args = {
176174
};
177175

178176
export const Focused = Template.bind({});
177+
Focused.storyName = "Keyboard Focused";
179178
Focused.args = {
180179
helpText: "Please select a country",
181-
isFocused: true,
180+
isKeyboardFocused: true,
182181
content: [
183182
() => MenuStories(MenuStories.args)
184183
],

components/picker/stories/template.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const Picker = ({
1818
labelPosition,
1919
placeholder,
2020
isQuiet = false,
21-
isFocused = false,
21+
isKeyboardFocused = false,
2222
isOpen = false,
2323
isInvalid = false,
2424
isLoading = false,
@@ -52,7 +52,7 @@ export const Picker = ({
5252
[`is-invalid`]: isInvalid,
5353
[`is-open`]: isOpen,
5454
[`is-loading`]: isLoading,
55-
[`is-focused`]: isFocused,
55+
[`is-keyboardFocused`]: isKeyboardFocused,
5656
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
5757
})}
5858
?disabled=${isDisabled}
@@ -96,7 +96,7 @@ export const Template = ({
9696
placeholder,
9797
helpText,
9898
isQuiet = false,
99-
isFocused = false,
99+
isKeyboardFocused = false,
100100
isOpen = false,
101101
isInvalid = false,
102102
isLoading = false,
@@ -151,7 +151,7 @@ export const Template = ({
151151
size,
152152
placeholder,
153153
isQuiet,
154-
isFocused,
154+
isKeyboardFocused,
155155
isOpen,
156156
isInvalid,
157157
isLoading,
@@ -173,7 +173,7 @@ export const Template = ({
173173
size,
174174
placeholder,
175175
isQuiet,
176-
isFocused,
176+
isKeyboardFocused,
177177
isOpen,
178178
isInvalid,
179179
isLoading,

0 commit comments

Comments
 (0)