@thecb/components 10.5.0-beta.1 → 10.5.0-beta.2

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 CHANGED
@@ -46304,14 +46304,25 @@ var Modal$1 = function Modal(_ref) {
46304
46304
  blurUnderlay = _ref$blurUnderlay === void 0 ? true : _ref$blurUnderlay;
46305
46305
  var _useContext = React.useContext(styled.ThemeContext),
46306
46306
  isMobile = _useContext.isMobile;
46307
- var modalContainerRef = React.useRef(null);
46307
+
46308
+ // `AriaModal` uses `focus-trap` as a transient dependency. It automatically looks
46309
+ // for a tabbable node when the modal mounts. When it doesn't find one, it looks to
46310
+ // the `fallbackFocus` option. However, React does not guarantee the ref supplied to
46311
+ // this option will be populated on initial render when `focus-trap` is checking
46312
+ // these option. When there are no buttons in the modal, this causes an error.
46313
+ // Because `focus-trap` cannot be disabled, the ref requires a dummy node to satisfy
46314
+ // `focus-trap` until React populates it with the real ref value.
46315
+ //
46316
+ // See:
46317
+ // - https://react.dev/reference/react/useRef#caveats
46318
+ // - https://github.com/davidtheclark/react-aria-modal/pull/103
46319
+ var modalContainerRef = React.useRef( /*#__PURE__*/React__default.createElement("div", null));
46308
46320
  return /*#__PURE__*/React__default.createElement("div", {
46309
46321
  ref: modalContainerRef,
46310
46322
  "data-qa": dataQa
46311
- }, modalOpen && /*#__PURE__*/React__default.createElement(reactAriaModal
46312
- // fallback to resolve Jest unit test errors when tabbable doesn't exist in jsdom https://github.com/focus-trap/focus-trap-react/issues/91
46313
- , {
46323
+ }, modalOpen && /*#__PURE__*/React__default.createElement(reactAriaModal, {
46314
46324
  focusTrapOptions: {
46325
+ // fallback to resolve Jest unit test errors when tabbable doesn't exist in jsdom https://github.com/focus-trap/focus-trap-react/issues/91
46315
46326
  fallbackFocus: modalContainerRef === null || modalContainerRef === void 0 ? void 0 : modalContainerRef.current
46316
46327
  },
46317
46328
  onExit: onExit,
@@ -46614,17 +46625,29 @@ var Modal$2 = function Modal(_ref) {
46614
46625
  useDangerButton = _ref$useDangerButton === void 0 ? false : _ref$useDangerButton;
46615
46626
  var _useContext = React.useContext(styled.ThemeContext),
46616
46627
  isMobile = _useContext.isMobile;
46617
- var modalContainerRef = React.useRef(null);
46628
+
46629
+ // `AriaModal` uses `focus-trap` as a transient dependency. It automatically looks
46630
+ // for a tabbable node when the modal mounts. When it doesn't find one, it looks to
46631
+ // the `fallbackFocus` option. However, React does not guarantee the ref supplied to
46632
+ // this option will be populated on initial render when `focus-trap` is checking
46633
+ // these option. When there are no buttons in the modal, this causes an error.
46634
+ // Because `focus-trap` cannot be disabled, the ref requires a dummy node to satisfy
46635
+ // `focus-trap` until React populates it with the real ref value.
46636
+ //
46637
+ // See:
46638
+ // - https://react.dev/reference/react/useRef#caveats
46639
+ // - https://github.com/davidtheclark/react-aria-modal/pull/103
46640
+ var modalContainerRef = React.useRef( /*#__PURE__*/React__default.createElement("div", null));
46618
46641
  var hasCloseButton = onlyCloseButton && !noButtons;
46619
46642
  var hasCancelButton = !onlyContinueButton && !onlyCloseButton && !noButtons;
46620
46643
  var hasContinueButton = onlyContinueButton && !noButtons || !onlyCloseButton && !noButtons;
46621
46644
  return /*#__PURE__*/React__default.createElement("div", {
46622
46645
  ref: modalContainerRef,
46646
+ tabIndex: "-1",
46623
46647
  "data-qa": dataQa
46624
- }, modalOpen && /*#__PURE__*/React__default.createElement(reactAriaModal
46625
- // fallback to resolve Jest unit test errors when tabbable doesn't exist in jsdom https://github.com/focus-trap/focus-trap-react/issues/91
46626
- , {
46648
+ }, modalOpen && /*#__PURE__*/React__default.createElement(reactAriaModal, {
46627
46649
  focusTrapOptions: {
46650
+ // fallback to resolve Jest unit test errors when tabbable doesn't exist in jsdom https://github.com/focus-trap/focus-trap-react/issues/91
46628
46651
  fallbackFocus: modalContainerRef === null || modalContainerRef === void 0 ? void 0 : modalContainerRef.current
46629
46652
  },
46630
46653
  onExit: onExit,