@applicaster/zapp-react-dom-app 13.0.0-rc.35 → 13.0.0-rc.37

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.
@@ -140,13 +140,16 @@ class InteractionManagerClass extends React.Component<Props, State> {
140
140
  this.onConfirmDialogOpen = this.onConfirmDialogOpen.bind(this);
141
141
  this.onConfirmDialogClose = this.onConfirmDialogClose.bind(this);
142
142
 
143
+ this.handlePhysicalKeyboardDismiss =
144
+ this.handlePhysicalKeyboardDismiss.bind(this);
145
+
143
146
  this.confirmDialog.setConfirmAction(this.performExit);
144
147
  this.confirmDialog.setCancelAction(this.onConfirmDialogClose);
145
148
  this.longPressDetector = new KeyboardLongPressManager();
146
149
  }
147
150
 
148
151
  componentDidMount() {
149
- window.addEventListener("keydown", this.onKeyDownListener);
152
+ window.addEventListener("keydown", this.onKeyDownListener, true);
150
153
  window.addEventListener("keyup", this.onKeyUp);
151
154
  window.addEventListener("mousemove", this.onMouseMoveListener);
152
155
 
@@ -181,6 +184,11 @@ class InteractionManagerClass extends React.Component<Props, State> {
181
184
  "onLongPressRelease",
182
185
  this.handleLongPressRelease.bind(this)
183
186
  );
187
+
188
+ document.addEventListener(
189
+ "keyboardDismissedByPhysicalKeypress",
190
+ this.handlePhysicalKeyboardDismiss
191
+ );
184
192
  }
185
193
 
186
194
  componentWillUnmount() {
@@ -209,6 +217,11 @@ class InteractionManagerClass extends React.Component<Props, State> {
209
217
  "onLongPressRelease",
210
218
  this.handleLongPressRelease
211
219
  );
220
+
221
+ document.removeEventListener(
222
+ "keyboardDismissedByPhysicalKeypress",
223
+ this.handlePhysicalKeyboardDismiss
224
+ );
212
225
  }
213
226
 
214
227
  performExit() {
@@ -448,20 +461,13 @@ class InteractionManagerClass extends React.Component<Props, State> {
448
461
  }
449
462
 
450
463
  /**
451
- When pressing backspace or the Native "Back" button:
464
+ When pressing escape or the Native "Back" button:
452
465
  if on the transport controls: we show the player
453
466
  if on the player : we show the UI
454
467
  if on the UI : we exit the app
468
+ note: backspace affects the keyboard input, so it not handled here
455
469
  */
456
-
457
- if (
458
- keyCode(event).matchesAny(
459
- KEYS.Back,
460
- KEYS.Escape,
461
- KEYS.EscapeDevice,
462
- KEYS.Backspace
463
- )
464
- ) {
470
+ if (keyCode(event).matchesAny(KEYS.Back, KEYS.Escape, KEYS.EscapeDevice)) {
465
471
  switch (displayState) {
466
472
  case DISPLAY_STATES.DEFAULT:
467
473
  case DISPLAY_STATES.PLAYER:
@@ -510,6 +516,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
510
516
  if (displayState === DISPLAY_STATES.PLAYER) {
511
517
  setDisplayState(DISPLAY_STATES.HUD);
512
518
  } else {
519
+ focusManager.pressIn();
513
520
  focusManager.press();
514
521
  }
515
522
 
@@ -542,12 +549,6 @@ class InteractionManagerClass extends React.Component<Props, State> {
542
549
  focusManager.moveFocus(direction);
543
550
  }
544
551
 
545
- if (!isDialogVisible) {
546
- // run focus recovery on user interaction attempt
547
- // probably we failed to set initial focus for some reason
548
- focusManager.recoverFocus();
549
- }
550
-
551
552
  if (
552
553
  displayState === DISPLAY_STATES.PLAYER ||
553
554
  displayState === DISPLAY_STATES.HUD
@@ -652,7 +653,7 @@ class InteractionManagerClass extends React.Component<Props, State> {
652
653
  }
653
654
  }
654
655
 
655
- handleKeyboardDismiss = () => {
656
+ handleKeyboardDismiss() {
656
657
  this.isDismissing = true;
657
658
 
658
659
  this.setState(
@@ -663,9 +664,10 @@ class InteractionManagerClass extends React.Component<Props, State> {
663
664
  },
664
665
  () => {
665
666
  this.isDismissing = false;
667
+ focusManager.recoverFocus();
666
668
  }
667
669
  );
668
- };
670
+ }
669
671
 
670
672
  handleKeyboardInput = (value: string) => {
671
673
  const { activeInputRef } = this.state;
@@ -761,6 +763,35 @@ class InteractionManagerClass extends React.Component<Props, State> {
761
763
  ].includes(event.code);
762
764
  }
763
765
 
766
+ handlePhysicalKeyboardDismiss(event: CustomEvent) {
767
+ const { value, position, inputElement } = event.detail;
768
+
769
+ this.isDismissing = true;
770
+
771
+ this.setState(
772
+ {
773
+ isKeyboardVisible: false,
774
+ keyboardInput: "",
775
+ activeInputRef: null,
776
+ },
777
+ () => {
778
+ if (inputElement) {
779
+ inputElement.value = value;
780
+ inputElement.focus();
781
+ inputElement.setSelectionRange(position, position);
782
+
783
+ const keyboardEvent = new CustomEvent("keyboardUpdate", {
784
+ detail: { value },
785
+ });
786
+
787
+ document.dispatchEvent(keyboardEvent);
788
+ }
789
+
790
+ this.isDismissing = false;
791
+ }
792
+ );
793
+ }
794
+
764
795
  render() {
765
796
  return (
766
797
  (shouldUseOnScreenKeyboard() && this.state.isKeyboardVisible && (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-dom-app",
3
- "version": "13.0.0-rc.35",
3
+ "version": "13.0.0-rc.37",
4
4
  "description": "Zapp App Component for Applicaster's Quick Brick React Native App",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "homepage": "https://github.com/applicaster/zapp-react-dom-app#readme",
24
24
  "dependencies": {
25
- "@applicaster/zapp-react-dom-ui-components": "13.0.0-rc.35",
26
- "@applicaster/zapp-react-native-bridge": "13.0.0-rc.35",
27
- "@applicaster/zapp-react-native-redux": "13.0.0-rc.35",
28
- "@applicaster/zapp-react-native-ui-components": "13.0.0-rc.35",
29
- "@applicaster/zapp-react-native-utils": "13.0.0-rc.35",
25
+ "@applicaster/zapp-react-dom-ui-components": "13.0.0-rc.37",
26
+ "@applicaster/zapp-react-native-bridge": "13.0.0-rc.37",
27
+ "@applicaster/zapp-react-native-redux": "13.0.0-rc.37",
28
+ "@applicaster/zapp-react-native-ui-components": "13.0.0-rc.37",
29
+ "@applicaster/zapp-react-native-utils": "13.0.0-rc.37",
30
30
  "abortcontroller-polyfill": "^1.7.5",
31
31
  "react-router-dom": "^5.1.2",
32
32
  "typeface-montserrat": "^0.0.54",