@microbit/ui 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microbit/ui",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "micro:bit design-system primitives: react-aria-components + Panda CSS with a design language ported from Chakra UI v2. Ships as source; see README for the consumption setup.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -49,11 +49,11 @@ export const input = defineRecipe({
49
49
  "&&&:is([data-invalid], :user-invalid)": {
50
50
  borderColor: "danger.500",
51
51
  },
52
- // Modality-tracked: RAC's attribute, or Input.tsx's. Native
52
+ // Modality-tracked: RAC's attribute, or Input/NativeSelect's. Native
53
53
  // :focus-visible is the fallback for a bare element wearing the recipe,
54
- // but not text-entry ones — browsers match it there on a pointer click,
55
- // which is what the tracking exists to exclude.
56
- "&&&:is([data-focus-visible], :focus-visible:not([data-rac], input, textarea))":
54
+ // but not form controls — browsers match it there on a pointer click
55
+ // (Chrome includes select), which is what the tracking exists to exclude.
56
+ "&&&:is([data-focus-visible], :focus-visible:not([data-rac], input, textarea, select))":
57
57
  {
58
58
  focusRing: "outline",
59
59
  },
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
6
  import { forwardRef, SelectHTMLAttributes } from "react";
7
+ import { mergeProps, useFocusRing } from "react-aria";
7
8
  import { css, cx } from "styled-system/css";
8
9
  import { input, InputVariantProps } from "styled-system/recipes";
9
10
  import { SystemStyleObject } from "styled-system/types";
@@ -40,9 +41,14 @@ export const NativeSelect = forwardRef<HTMLSelectElement, NativeSelectProps>(
40
41
  { hideChevron = false, size, css: cssProp, wrapperCss, className, ...rest },
41
42
  ref,
42
43
  ) {
44
+ // Modality tracked here rather than via the recipe's native
45
+ // :focus-visible fallback: Chrome matches that on a clicked select (as it
46
+ // does on text inputs), and this ring is keyboard-only.
47
+ const { isFocusVisible, focusProps } = useFocusRing();
43
48
  const select = (
44
49
  <select
45
50
  ref={ref}
51
+ data-focus-visible={isFocusVisible || undefined}
46
52
  className={cx(
47
53
  input({ size }),
48
54
  css(
@@ -59,7 +65,7 @@ export const NativeSelect = forwardRef<HTMLSelectElement, NativeSelectProps>(
59
65
  ),
60
66
  className,
61
67
  )}
62
- {...rest}
68
+ {...mergeProps(rest, focusProps)}
63
69
  />
64
70
  );
65
71
  if (hideChevron) {