Pārlūkot izejas kodu

fix(FocusLock): Stop stealing focus when embedded

j8
Mihai-Andrei Uscat 4 gadus atpakaļ
vecāks
revīzija
e33674fb2e
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
2 mainītis faili ar 19 papildinājumiem un 23 dzēšanām
  1. 1
    0
      package.json
  2. 18
    23
      react/features/base/util/react-focus-lock-wrapper.js

+ 1
- 0
package.json Parādīt failu

@@ -67,6 +67,7 @@
67 67
     "react": "16.12",
68 68
     "react-dom": "16.12",
69 69
     "react-emoji-render": "1.2.4",
70
+    "react-focus-lock": "2.5.1",
70 71
     "react-i18next": "10.11.4",
71 72
     "react-linkify": "1.0.0-alpha",
72 73
     "react-native": "github:jitsi/react-native#891986ec5ecaef65d1c8a7fe472f86cf84fe7551",

+ 18
- 23
react/features/base/util/react-focus-lock-wrapper.js Parādīt failu

@@ -6,31 +6,26 @@ import FocusLock, { MoveFocusInside } from 'react-focus-lock';
6 6
  * FocusLock wrapper that disable the FocusLock in the @atlaskit/modal-dialog. We need to disable it because if the
7 7
  * iframe API is used and a dialog is displayed it is impossible to click on fields outside of the iframe (FocusLock
8 8
  * will steal the focus from any element that is not part of the dialog).
9
+ *
10
+ * @param {Object} props - The props passed to the FocusLock.
11
+ * @returns {ReactElement}
9 12
  */
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;
13
+export default (props: Object) => {
14
+    const { children, ...otherProps } = props;
19 15
 
20
-        const props = {
21
-            ...otherProps,
22
-            crossFrame: false
23
-        };
16
+    const forwardProps = {
17
+        ...otherProps,
18
+        crossFrame: false
19
+    };
24 20
 
25
-        // MoveFocusInside is added in order to initially bring the focus on the dialog.
26
-        return (
27
-            <FocusLock
28
-                { ...props }
29
-                className = 'focus-lock'>
30
-                <MoveFocusInside>{children}</MoveFocusInside>
31
-            </FocusLock>
32
-        );
33
-    }
34
-}
21
+    // MoveFocusInside is added in order to initially bring the focus on the dialog.
22
+    return (
23
+        <FocusLock
24
+            { ...forwardProps }
25
+            className = 'focus-lock'>
26
+            <MoveFocusInside>{children}</MoveFocusInside>
27
+        </FocusLock>
28
+    );
29
+};
35 30
 
36 31
 export * from 'react-focus-lock';

Notiek ielāde…
Atcelt
Saglabāt