@transferwise/components 0.0.0-experimental-e9526a8 → 0.0.0-experimental-d05d921

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.
@@ -1 +1 @@
1
- {"version":3,"file":"FocusBoundary.d.ts","sourceRoot":"","sources":["../../../../src/common/focusBoundary/FocusBoundary.tsx"],"names":[],"mappings":";AAEA,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,QAAA,MAAM,aAAa,iBAAkB,kBAAkB,gCAOtD,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"FocusBoundary.d.ts","sourceRoot":"","sources":["../../../../src/common/focusBoundary/FocusBoundary.tsx"],"names":[],"mappings":";AAGA,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF,QAAA,MAAM,aAAa,iBAAkB,kBAAkB,gCAatD,CAAC;AAEF,eAAe,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-e9526a8",
3
+ "version": "0.0.0-experimental-d05d921",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -6,13 +6,13 @@ exports[`BottomSheet renders content when open 1`] = `
6
6
  <div
7
7
  class="np-theme-light"
8
8
  >
9
- <span
10
- data-focus-scope-start="true"
11
- hidden=""
12
- />
13
9
  <div
14
10
  tabindex="-1"
15
11
  >
12
+ <span
13
+ data-focus-scope-start="true"
14
+ hidden=""
15
+ />
16
16
  <div
17
17
  class="dimmer"
18
18
  role="presentation"
@@ -66,11 +66,11 @@ exports[`BottomSheet renders content when open 1`] = `
66
66
  </div>
67
67
  </div>
68
68
  </div>
69
+ <span
70
+ data-focus-scope-end="true"
71
+ hidden=""
72
+ />
69
73
  </div>
70
- <span
71
- data-focus-scope-end="true"
72
- hidden=""
73
- />
74
74
  </div>
75
75
  </body>
76
76
  `;
@@ -1,15 +1,22 @@
1
1
  import { FocusScope } from '@react-aria/focus';
2
+ import { useEffect, useRef } from 'react';
2
3
 
3
4
  type FocusBoundaryProps = {
4
5
  children: React.ReactNode;
5
6
  };
6
7
 
7
8
  const FocusBoundary = ({ children }: FocusBoundaryProps) => {
9
+ const wrapperReference = useRef<HTMLDivElement>(null);
10
+ useEffect(() => {
11
+ wrapperReference.current?.focus({ preventScroll: true });
12
+ }, []);
13
+
8
14
  return (
9
- // eslint-disable-next-line jsx-a11y/no-autofocus
10
- <FocusScope contain restoreFocus autoFocus>
11
- <div tabIndex={-1}>{children}</div>
12
- </FocusScope>
15
+ <div ref={wrapperReference} tabIndex={-1}>
16
+ <FocusScope contain restoreFocus>
17
+ {children}
18
+ </FocusScope>
19
+ </div>
13
20
  );
14
21
  };
15
22