@thecb/components 6.0.0-beta.5 → 6.0.0-beta.8

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": "@thecb/components",
3
- "version": "6.0.0-beta.5",
3
+ "version": "6.0.0-beta.8",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -19,6 +19,7 @@ const CountryDropdown = ({
19
19
  errorMessages={errorMessages}
20
20
  showErrors={showErrors}
21
21
  onChange={onChange}
22
+ autocompleteValue="country-name"
22
23
  />
23
24
  );
24
25
  export default CountryDropdown;
@@ -74,11 +74,10 @@ const DropdownItemWrapper = styled.div`
74
74
 
75
75
  const SearchInput = styled.input`
76
76
  border: none;
77
- background-color: ${({ themeValues, isOpen }) =>
78
- isOpen ? themeValues.hoverColor && themeValues.hoverColor : "WHITE"};
77
+ background-color: transparent;
79
78
  font-size: 16px;
80
79
  height: 24px;
81
- min-width: 75%;
80
+ min-width: 80%;
82
81
  `;
83
82
 
84
83
  const Dropdown = ({
@@ -96,7 +95,8 @@ const Dropdown = ({
96
95
  disabled,
97
96
  hasTitles = false,
98
97
  autoEraseTypeAhead = true, // legacy behavior as of 05/22
99
- ariaLabelledby
98
+ ariaLabelledby,
99
+ autocompleteValue = "" // autofill item for browsers, like country-name or address-level1 for state
100
100
  }) => {
101
101
  const [inputValue, setInputValue] = useState("");
102
102
  const [optionsState, setOptionsState] = useState([]);
@@ -122,6 +122,7 @@ const Dropdown = ({
122
122
  value ? options.find(option => option.value === value)?.text : placeholder;
123
123
 
124
124
  const onKeyDown = e => {
125
+ console.log("key down event is", e);
125
126
  const { key, keyCode } = e;
126
127
  const focus = document.activeElement;
127
128
  console.log("dropdown value is", value);
@@ -183,13 +184,14 @@ const Dropdown = ({
183
184
  };
184
185
 
185
186
  useEffect(() => {
187
+ console.log("option refs in isopen useffect", optionRefs);
186
188
  console.log(
187
- "option refs in isopen useffect",
189
+ "option ref current in isopen useffect",
188
190
  optionRefs.current[0].current
189
191
  );
190
192
  console.log("selected refs in isopen useffect", selectedRef);
191
193
  console.log("value in isopen useffect", value);
192
- if (isOpen && selectedRef !== undefined) {
194
+ if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
193
195
  // WAI-ARIA requires the selected option to receive focus
194
196
  selectedRef.current.focus();
195
197
  } else if (isOpen && optionRefs.current[0].current) {
@@ -203,7 +205,7 @@ const Dropdown = ({
203
205
  useEffect(() => {
204
206
  if (autoEraseTypeAhead) {
205
207
  clearTimeout(timer);
206
- setTimer(setTimeout(() => setInputValue(""), 2000));
208
+ setTimer(setTimeout(() => setInputValue(""), 3000));
207
209
  }
208
210
  setFilteredOptions(
209
211
  options.filter(
@@ -221,6 +223,8 @@ const Dropdown = ({
221
223
  !disabledValues.includes(filteredOptions[0].value) &&
222
224
  filteredOptions[0].text != placeholder
223
225
  ) {
226
+ console.log("filtered options are", filteredOptions);
227
+ console.log("option refs are", optionRefs);
224
228
  onSelect(filteredOptions[0].value);
225
229
  }
226
230
  if (optionRefs.current[0].current) {
@@ -274,12 +278,18 @@ const Dropdown = ({
274
278
  pointer-events: none;`}
275
279
  `}
276
280
  >
277
- <Stack direction="row" bottomItem={2}>
281
+ <Stack
282
+ direction="row"
283
+ bottomItem={2}
284
+ extraStyles={`position: relative;`}
285
+ >
278
286
  <SearchInput
279
287
  aria-label={getSelection()}
280
288
  placeholder={getSelection()}
281
289
  value={inputValue}
282
- onChange={noop}
290
+ onChange={e => {
291
+ console.log("input change event", e);
292
+ }}
283
293
  themeValues={themeValues}
284
294
  role="searchbox"
285
295
  type="text"
@@ -288,6 +298,9 @@ const Dropdown = ({
288
298
  aria-controls={`${ariaLabelledby}_listbox`}
289
299
  aria-activedescendant="selected_option"
290
300
  isOpen={isOpen}
301
+ tabIndex={-1}
302
+ name={autocompleteValue}
303
+ autocomplete={autocompleteValue}
291
304
  />
292
305
  <IconWrapper open={isOpen}>
293
306
  <DropdownIcon />
@@ -19,7 +19,8 @@ const FormSelect = ({
19
19
  disabledValues,
20
20
  disabled,
21
21
  themeValues,
22
- hasTitles = false
22
+ hasTitles = false,
23
+ autocompleteValue // autofill item for browsers, like country-name or address-level1 for state
23
24
  }) => {
24
25
  const [open, setOpen] = useState(false);
25
26
  const dropdownRef = useRef(null);
@@ -74,6 +75,7 @@ const FormSelect = ({
74
75
  }
75
76
  onClick={() => setOpen(!open)}
76
77
  disabled={disabled}
78
+ autocompleteValue={autocompleteValue}
77
79
  />
78
80
  <Stack direction="row" justify="space-between">
79
81
  {(field.hasErrors && field.dirty) || (field.hasErrors && showErrors) ? (
@@ -22,6 +22,7 @@ const FormStateDropdown = ({
22
22
  labelTextWhenNoError={labelTextWhenNoError}
23
23
  errorMessages={errorMessages}
24
24
  showErrors={showErrors}
25
+ autocompleteValue="address-level1"
25
26
  />
26
27
  );
27
28
  };