@jobber/components-native 0.63.0 → 0.65.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.65.0",
4
4
  "license": "MIT",
5
5
  "description": "React Native implementation of Atlantis",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "build:clean": "rm -rf ./dist"
37
37
  },
38
38
  "dependencies": {
39
- "@jobber/design": "^0.56.4",
39
+ "@jobber/design": "^0.57.0",
40
40
  "@jobber/hooks": "^2.9.4",
41
41
  "@react-native-clipboard/clipboard": "^1.11.2",
42
42
  "@react-native-picker/picker": "^2.4.10",
@@ -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": "3eb2d707a233210b3d0612acf0baf25e7291cb53"
88
88
  }
@@ -6,7 +6,7 @@ import { Text } from "../Text";
6
6
 
7
7
  describe("ActionItem", () => {
8
8
  const pressHandler = jest.fn();
9
- const defaultActionIcon = "arrowRight";
9
+ const defaultActionIcon = "longArrowRight";
10
10
 
11
11
  beforeEach(() => {
12
12
  jest.resetAllMocks();
@@ -63,7 +63,7 @@ describe("ActionItem", () => {
63
63
  expect(queryByTestId(defaultActionIcon)).toBeFalsy();
64
64
  });
65
65
 
66
- it("should display arrowRight icon when edit name is used", () => {
66
+ it("should display longArrowRight icon when edit name is used", () => {
67
67
  const iconName = "edit";
68
68
  const { getByTestId } = render(
69
69
  <ActionItem onPress={pressHandler} actionIcon={iconName} />,
@@ -124,7 +124,7 @@ type ActionIconNames = IconNames | "editpencil";
124
124
 
125
125
  function getActionIcon(icon: ActionIconNames): IconNames {
126
126
  if (icon === "edit") {
127
- return "arrowRight";
127
+ return "longArrowRight";
128
128
  } else if (icon === "editpencil") {
129
129
  return "edit";
130
130
  }
@@ -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
  }