|
@@ -0,0 +1,30 @@
|
|
1
|
+// @flow
|
|
2
|
+import React from 'react';
|
|
3
|
+import FocusLock, { MoveFocusInside } from 'react-focus-lock';
|
|
4
|
+
|
|
5
|
+/**
|
|
6
|
+ * FocusLock wrapper that disable the FocusLock in the @atlaskit/modal-dialog. We need to disable it because if the
|
|
7
|
+ * iframe API is used and a dialog is displayed it is imposible to click on fields outside of the iframe (FocusLock
|
|
8
|
+ * will steal the focus from any element that is not part of the dialog).
|
|
9
|
+ */
|
|
10
|
+export default class FocusLockWrapper extends FocusLock<*> {
|
|
11
|
+ /**
|
|
12
|
+ * Implements React's {@link Component#render()}.
|
|
13
|
+ *
|
|
14
|
+ * @inheritdoc
|
|
15
|
+ * @returns {ReactElement}
|
|
16
|
+ */
|
|
17
|
+ render() {
|
|
18
|
+ const { children, ...otherProps } = this.props;
|
|
19
|
+
|
|
20
|
+ const props = {
|
|
21
|
+ ...otherProps,
|
|
22
|
+ disabled: true
|
|
23
|
+ };
|
|
24
|
+
|
|
25
|
+ // MoveFocusInside is added in order to initially bring the focus on the dialog.
|
|
26
|
+ return <FocusLock { ...props } ><MoveFocusInside>{children}</MoveFocusInside></FocusLock>;
|
|
27
|
+ }
|
|
28
|
+}
|
|
29
|
+
|
|
30
|
+export * from 'react-focus-lock';
|