@jobber/components-native 0.63.0 → 0.64.0

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": "@jobber/components-native",
3
- "version": "0.63.0",
3
+ "version": "0.64.0",
4
4
  "license": "MIT",
5
5
  "description": "React Native implementation of Atlantis",
6
6
  "repository": {
@@ -84,5 +84,5 @@
84
84
  "react-native-safe-area-context": "^4.5.2",
85
85
  "react-native-svg": ">=12.0.0"
86
86
  },
87
- "gitHead": "15034baa004c4a11f17338b96d6f2678f3183d56"
87
+ "gitHead": "2cf5b8fafc67e021899124f3fd885de116bc374e"
88
88
  }
@@ -9,7 +9,7 @@ export const styles = StyleSheet.create({
9
9
  backgroundColor: tokens["color-surface"],
10
10
  paddingHorizontal: tokens["space-small"],
11
11
  paddingVertical: tokens["space-small"] + tokens["space-smallest"],
12
- borderRadius: tokens["radius-larger"],
12
+ borderRadius: tokens["radius-base"],
13
13
  width: menuWidth,
14
14
  ...tokens["shadow-high"],
15
15
  },
package/src/Menu/Menu.tsx CHANGED
@@ -1,6 +1,8 @@
1
1
  import React, { useCallback, useRef, useState } from "react";
2
2
  import {
3
+ Keyboard,
3
4
  LayoutRectangle,
5
+ Platform,
4
6
  Pressable,
5
7
  View,
6
8
  useWindowDimensions,
@@ -33,7 +35,7 @@ export function Menu({ menuOptions, customActivator }: MenuProps): JSX.Element {
33
35
  }
34
36
  }, [screenInfo, activatorLayout]);
35
37
 
36
- const activatorOnPress = (onPress?: () => void) => {
38
+ const openMenu = () => {
37
39
  menuButtonRef.current?.measureInWindow(
38
40
  (x: number, y: number, width: number, height: number) => {
39
41
  activatorLayout.current = {
@@ -44,11 +46,23 @@ export function Menu({ menuOptions, customActivator }: MenuProps): JSX.Element {
44
46
  };
45
47
  findMenuLayout();
46
48
  setOpen(true);
47
- onPress && onPress();
48
49
  },
49
50
  );
50
51
  };
51
52
 
53
+ const activatorOnPress = (onPress?: () => void) => {
54
+ onPress && onPress();
55
+
56
+ if (Platform.OS === "ios" && Keyboard.isVisible()) {
57
+ // On iOS, the keyboard height causes problems with the menu positioning logic.
58
+ // Wait until the keyboard is fully hidden before we show the menu.
59
+ onKeyboardDidHide(openMenu);
60
+ Keyboard.dismiss();
61
+ } else {
62
+ openMenu();
63
+ }
64
+ };
65
+
52
66
  return (
53
67
  <>
54
68
  <View
@@ -113,3 +127,10 @@ function useScreenInformation() {
113
127
 
114
128
  return { headerHeight, windowWidth, windowHeight };
115
129
  }
130
+
131
+ function onKeyboardDidHide(callback: () => void) {
132
+ const listener = Keyboard.addListener("keyboardDidHide", () => {
133
+ listener.remove();
134
+ callback();
135
+ });
136
+ }
package/src/Menu/utils.ts CHANGED
@@ -118,12 +118,7 @@ function getLeftPosition(
118
118
  } else if (overflowRight) {
119
119
  pos.right = 0;
120
120
  } else {
121
- pos.right =
122
- windowWidth -
123
- activatorLayout.x -
124
- activatorLayout.width +
125
- activatorLayout.width / 2 -
126
- menuHorizontalPadding;
121
+ pos.right = windowWidth - activatorLayout.x - activatorLayout.width;
127
122
  }
128
123
  }
129
124
 
@@ -147,6 +142,6 @@ function getRightPosition(
147
142
  } else if (overflowLeft) {
148
143
  pos.left = 0;
149
144
  } else {
150
- pos.left = activatorLayout.x + activatorLayout.width / 2 - menuPadding;
145
+ pos.left = activatorLayout.x;
151
146
  }
152
147
  }