@thecb/components 7.0.0-beta.0 → 7.0.0-beta.1

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": "7.0.0-beta.0",
3
+ "version": "7.0.0-beta.1",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import React, { Fragment, useContext } from "react";
1
+ import React, { Fragment, useContext, useRef } from "react";
2
2
  import { ThemeContext } from "styled-components";
3
3
  import AriaModal from "react-aria-modal";
4
4
  import { WHITE, ATHENS_GREY, SILVER_GREY } from "../../../constants/colors";
@@ -47,11 +47,14 @@ const Modal = ({
47
47
  children
48
48
  }) => {
49
49
  const { isMobile } = useContext(ThemeContext);
50
+ const closeBtnRef = useRef(null);
51
+ const modalBodyTextRef = useRef(null);
50
52
  return (
51
53
  <Fragment>
52
54
  {modalOpen && (
53
55
  <AriaModal
54
- focusDialog={true}
56
+ initialFocus={closeBtnRef || modalBodyTextRef}
57
+ focusTrapOptions={{ delayInitialFocus: false, fallbackFocus: closeBtnRef || modalBodyTextRef }} // fallback to resolve unit test errors https://github.com/focus-trap/focus-trap-react/issues/91
55
58
  onExit={onExit}
56
59
  getApplicationNode={getApplicationNode}
57
60
  titleText={modalHeaderText}
@@ -81,6 +84,7 @@ const Modal = ({
81
84
  <Box background={modalBodyBg} padding="1.5rem">
82
85
  <Stack childGap="1.5rem">
83
86
  <Box
87
+ ref={modalBodyTextRef}
84
88
  borderWidthOverride={noBorder && "0 0 2px 0"}
85
89
  borderColor={!noBorder && SILVER_GREY}
86
90
  padding={!noBorder && "0 0 1.5rem 0"}
@@ -170,6 +174,7 @@ const Modal = ({
170
174
  ) : (
171
175
  <Box padding="0.5rem">
172
176
  <ButtonWithAction
177
+ ref={closeBtnRef}
173
178
  action={hideModal}
174
179
  variant="primary"
175
180
  text={closeButtonText}