@kaizen/components 2.0.3 → 2.0.4

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.
@@ -60,10 +60,14 @@ var ListBox = function (_a) {
60
60
  var optionKey = getOptionKeyFromCollection(state);
61
61
  var focusToElement = safeQuerySelector("[data-key='".concat(optionKey, "']"));
62
62
  if (focusToElement) {
63
- focusToElement.focus();
63
+ focusToElement.focus({
64
+ preventScroll: true
65
+ });
64
66
  } else {
65
67
  // If an element is not found, focus on the listbox. This ensures the list can still be navigated to via keyboard if the keys do not align to the data attributes of the list items.
66
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
68
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus({
69
+ preventScroll: true
70
+ });
67
71
  }
68
72
  }
69
73
  // Only run this effect for checking the first successful render
@@ -52,10 +52,14 @@ const ListBox = /*#__PURE__*/function () {
52
52
  var optionKey = getOptionKeyFromCollection(state);
53
53
  var focusToElement = safeQuerySelector("[data-key='".concat(optionKey, "']"));
54
54
  if (focusToElement) {
55
- focusToElement.focus();
55
+ focusToElement.focus({
56
+ preventScroll: true
57
+ });
56
58
  } else {
57
59
  // If an element is not found, focus on the listbox. This ensures the list can still be navigated to via keyboard if the keys do not align to the data attributes of the list items.
58
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
60
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus({
61
+ preventScroll: true
62
+ });
59
63
  }
60
64
  }
61
65
  // Only run this effect for checking the first successful render
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaizen/components",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "Kaizen component library",
5
5
  "author": "Geoffrey Chong <geoff.chong@cultureamp.com>",
6
6
  "homepage": "https://cultureamp.design",
@@ -70,10 +70,10 @@ export const ListBox = <Option extends SingleSelectOption>({
70
70
  const focusToElement = safeQuerySelector(`[data-key='${optionKey}']`)
71
71
 
72
72
  if (focusToElement) {
73
- focusToElement.focus()
73
+ focusToElement.focus({ preventScroll: true })
74
74
  } else {
75
75
  // If an element is not found, focus on the listbox. This ensures the list can still be navigated to via keyboard if the keys do not align to the data attributes of the list items.
76
- ref.current?.focus()
76
+ ref.current?.focus({ preventScroll: true })
77
77
  }
78
78
  }
79
79
  // Only run this effect for checking the first successful render