@thecb/components 6.0.0-beta.18 → 6.0.0-beta.20

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.18",
3
+ "version": "6.0.0-beta.20",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -78,6 +78,7 @@
78
78
  },
79
79
  "dependencies": {
80
80
  "@babel/runtime": "^7.15.4",
81
+ "core-js": "^3.22.5",
81
82
  "formatted-input": "^1.0.0",
82
83
  "framer-motion": "^1.11.0",
83
84
  "numeral": "^2.0.6",
@@ -4,6 +4,8 @@ import Text from "../text";
4
4
  import { noop } from "../../../util/general";
5
5
  import DropdownIcon from "./DropdownIcon";
6
6
  import styled from "styled-components";
7
+ // support for Array.prototype.at() in older browsers
8
+ import "core-js/proposals/relative-indexing-method";
7
9
 
8
10
  import {
9
11
  WHITE,
@@ -173,9 +175,8 @@ const Dropdown = ({
173
175
  break;
174
176
  case "End":
175
177
  e.preventDefault();
176
- optionRefs.current[
177
- optionRefs?.current?.length ?? 0 - 1
178
- ].current.focus();
178
+ console.log("option refs current", optionRefs.current);
179
+ optionRefs.current.at(-1).current.focus();
179
180
  break;
180
181
  case "Escape":
181
182
  if (isOpen) {
@@ -191,15 +192,15 @@ const Dropdown = ({
191
192
  };
192
193
 
193
194
  const handleItemSelection = (evt, choice, i) => {
194
- disabledValues.includes(choice.value)
195
- ? evt => evt.preventDefault()
196
- : () => {
197
- setSelectedRef(optionRefs.current[i]);
198
- onSelect(choice.value);
199
- if (isOpen) {
200
- onClick();
201
- }
202
- };
195
+ if (disabledValues.includes(choice.value)) {
196
+ evt.preventDefault();
197
+ } else {
198
+ setSelectedRef(optionRefs.current[i]);
199
+ onSelect(choice.value);
200
+ if (isOpen) {
201
+ onClick();
202
+ }
203
+ }
203
204
  };
204
205
 
205
206
  useEffect(() => {