@thecb/components 6.0.0-beta.24 → 6.0.0-beta.27
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/dist/index.cjs.js +12 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +12 -4
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +4 -0
- package/src/components/atoms/layouts/Box.js +2 -0
- package/src/components/atoms/layouts/Box.styled.js +9 -1
package/package.json
CHANGED
|
@@ -121,6 +121,7 @@ const Dropdown = ({
|
|
|
121
121
|
const [timer, setTimer] = useState(null);
|
|
122
122
|
const optionRefs = useRef([...Array(options.length)].map(() => createRef()));
|
|
123
123
|
const dropdownRef = useRef(null);
|
|
124
|
+
const inputRef = useRef(null);
|
|
124
125
|
|
|
125
126
|
const getSelection = () =>
|
|
126
127
|
value ? options.find(option => option.value === value)?.text : placeholder;
|
|
@@ -208,9 +209,11 @@ const Dropdown = ({
|
|
|
208
209
|
if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
|
|
209
210
|
// WAI-ARIA requires the selected option to receive focus
|
|
210
211
|
selectedRef.current.focus();
|
|
212
|
+
console.log("input box ref", inputRef, inputRef.current);
|
|
211
213
|
} else if (isOpen && optionRefs.current[0].current) {
|
|
212
214
|
// If no selected option, first option receives focus
|
|
213
215
|
optionRefs.current[0].current.focus();
|
|
216
|
+
console.log("input box ref", inputRef, inputRef.current);
|
|
214
217
|
}
|
|
215
218
|
clearTimeout(timer);
|
|
216
219
|
setInputValue("");
|
|
@@ -313,6 +316,7 @@ const Dropdown = ({
|
|
|
313
316
|
}}
|
|
314
317
|
padding="12px"
|
|
315
318
|
placeholder={getSelection()}
|
|
319
|
+
ref={inputRef}
|
|
316
320
|
role="combobox"
|
|
317
321
|
themeValues={themeValues}
|
|
318
322
|
title={hasTitles ? getSelection() : null}
|
|
@@ -41,6 +41,7 @@ const Box = ({
|
|
|
41
41
|
hiddenStyles,
|
|
42
42
|
extraStyles,
|
|
43
43
|
srOnly = false,
|
|
44
|
+
ref,
|
|
44
45
|
dataQa,
|
|
45
46
|
children,
|
|
46
47
|
...rest
|
|
@@ -78,6 +79,7 @@ const Box = ({
|
|
|
78
79
|
onFocus={onFocus}
|
|
79
80
|
onBlur={onBlur}
|
|
80
81
|
onTouchEnd={onTouchEnd}
|
|
82
|
+
ref={ref}
|
|
81
83
|
{...rest}
|
|
82
84
|
>
|
|
83
85
|
{children && safeChildren(children, <Fragment />)}
|
|
@@ -29,8 +29,16 @@ export const BoxWrapper = styled(
|
|
|
29
29
|
hiddenStyles,
|
|
30
30
|
ariaControls,
|
|
31
31
|
ariaLabel,
|
|
32
|
+
ref,
|
|
32
33
|
...props
|
|
33
|
-
}) =>
|
|
34
|
+
}) => (
|
|
35
|
+
<div
|
|
36
|
+
aria-controls={ariaControls}
|
|
37
|
+
aria-label={ariaLabel}
|
|
38
|
+
ref={ref}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
)
|
|
34
42
|
)`
|
|
35
43
|
position: relative;
|
|
36
44
|
box-sizing: border-box;
|