@decisiv/ui-components 2.0.1-alpha.199 → 2.0.1-alpha.200

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.
@@ -56,7 +56,7 @@ var ResponsiveModalWrapper = function ResponsiveModalWrapper(_ref) {
56
56
  container = _useElement2[0],
57
57
  containerRef = _useElement2[1];
58
58
 
59
- (0, _utils.useKeepFocusWithin)(container);
59
+ (0, _utils.useKeepFocusWithin)(container, onClose !== undefined);
60
60
  var uuid = (0, _useUniqueId.default)(id, 'modal-');
61
61
  var modalHeaderId = "modal-header-".concat(uuid);
62
62
  var modalContentId = "modal-content-".concat(uuid);
@@ -1,4 +1,4 @@
1
1
  export declare function useReturnFocus(returnFocus: boolean): void;
2
2
  export declare function useElement(): [HTMLElement | null, (node: HTMLElement | null) => void];
3
- export declare function useKeepFocusWithin(container: HTMLElement | null): void;
3
+ export declare function useKeepFocusWithin(container: HTMLElement | null, hasCloseButton: boolean): void;
4
4
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/utils.tsx"],"names":[],"mappings":"AAaA,wBAAgB,cAAc,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAWzD;AAUD,wBAAgB,UAAU,IAAI,CAC5B,WAAW,GAAG,IAAI,EAClB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CACnC,CAUA;AAoCD,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAyDtE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/Modal/utils.tsx"],"names":[],"mappings":"AAaA,wBAAgB,cAAc,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAWzD;AAUD,wBAAgB,UAAU,IAAI,CAC5B,WAAW,GAAG,IAAI,EAClB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CACnC,CAUA;AAoCD,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,cAAc,EAAE,OAAO,GACtB,IAAI,CA2DN"}
@@ -95,19 +95,21 @@ function useTabbableElements(container) {
95
95
  */
96
96
 
97
97
 
98
- function useKeepFocusWithin(container) {
98
+ function useKeepFocusWithin(container, hasCloseButton) {
99
99
  var tabbableElements = useTabbableElements(container); // This effect should run only when the container changes from null to an element. Since
100
100
  // the component does not control the tabbable elements and they may be updated, we
101
101
  // don't want to automatically change the focus at any other time.
102
102
 
103
103
  (0, _react.useEffect)(function () {
104
104
  if (container && !(0, _isEmpty.default)(tabbableElements)) {
105
- // The first tabbable element will be the close button, but that isn't where
106
- // the user's focus should start. Instead, get the second tabbable element.
107
- var secondTabbable = (0, _get.default)(tabbableElements, 1, {
105
+ // Determine where to set the initial focus within the modal:
106
+ // - If the modal includes a close button, it will be the first tabbable element. However, user focus should not start there. Instead, move the focus to the second tabbable element.
107
+ // - If there is no close button, set the focus to the first tabbable element.
108
+ var focusElementIndex = hasCloseButton ? 1 : 0;
109
+ var focusElement = (0, _get.default)(tabbableElements, focusElementIndex, {
108
110
  focus: function focus() {}
109
111
  });
110
- secondTabbable.focus();
112
+ focusElement.focus();
111
113
  }
112
114
  }, [container]); // eslint-disable-line react-hooks/exhaustive-deps
113
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decisiv/ui-components",
3
- "version": "2.0.1-alpha.199+f09cd92",
3
+ "version": "2.0.1-alpha.200+acba5d1",
4
4
  "description": "Decisiv's design system React components",
5
5
  "author": "Decisiv UI Development Team",
6
6
  "license": "MIT",
@@ -71,5 +71,5 @@
71
71
  "access": "public"
72
72
  },
73
73
  "private": false,
74
- "gitHead": "f09cd929f1f2639d02830db24dee2f900fcc3769"
74
+ "gitHead": "acba5d12cd37ed776d447166a107a5345394fdb1"
75
75
  }