@wordpress/components 25.3.0 → 25.5.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.
Files changed (190) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/build/border-control/border-control-dropdown/component.js +8 -10
  3. package/build/border-control/border-control-dropdown/component.js.map +1 -1
  4. package/build/button/index.native.js +9 -6
  5. package/build/button/index.native.js.map +1 -1
  6. package/build/color-palette/index.js +2 -2
  7. package/build/color-palette/index.js.map +1 -1
  8. package/build/focal-point-picker/index.native.js +6 -4
  9. package/build/focal-point-picker/index.native.js.map +1 -1
  10. package/build/form-token-field/styles.js +4 -2
  11. package/build/form-token-field/styles.js.map +1 -1
  12. package/build/item-group/item/hook.js +1 -1
  13. package/build/item-group/item/hook.js.map +1 -1
  14. package/build/item-group/styles.js +13 -10
  15. package/build/item-group/styles.js.map +1 -1
  16. package/build/menu-items-choice/index.js +1 -0
  17. package/build/menu-items-choice/index.js.map +1 -1
  18. package/build/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js +3 -1
  19. package/build/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js.map +1 -1
  20. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +50 -44
  21. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  22. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +13 -20
  23. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  24. package/build/mobile/bottom-sheet/index.native.js +3 -1
  25. package/build/mobile/bottom-sheet/index.native.js.map +1 -1
  26. package/build/mobile/image/index.native.js +4 -3
  27. package/build/mobile/image/index.native.js.map +1 -1
  28. package/build/mobile/link-picker/link-picker-results.native.js +2 -1
  29. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  30. package/build/mobile/segmented-control/index.native.js +7 -7
  31. package/build/mobile/segmented-control/index.native.js.map +1 -1
  32. package/build/modal/index.js +14 -1
  33. package/build/modal/index.js.map +1 -1
  34. package/build/navigator/navigator-provider/component.js +18 -10
  35. package/build/navigator/navigator-provider/component.js.map +1 -1
  36. package/build/private-apis.js +4 -1
  37. package/build/private-apis.js.map +1 -1
  38. package/build/progress-bar/index.js +54 -0
  39. package/build/progress-bar/index.js.map +1 -0
  40. package/build/progress-bar/styles.js +69 -0
  41. package/build/progress-bar/styles.js.map +1 -0
  42. package/build/progress-bar/types.js +6 -0
  43. package/build/progress-bar/types.js.map +1 -0
  44. package/build/query-controls/index.js +1 -0
  45. package/build/query-controls/index.js.map +1 -1
  46. package/build/query-controls/index.native.js +1 -0
  47. package/build/query-controls/index.native.js.map +1 -1
  48. package/build/tab-panel/index.js +91 -58
  49. package/build/tab-panel/index.js.map +1 -1
  50. package/build/text-control/index.js +2 -2
  51. package/build/text-control/index.js.map +1 -1
  52. package/build/toolbar/toolbar-group/toolbar-group-container.native.js +10 -7
  53. package/build/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
  54. package/build-module/border-control/border-control-dropdown/component.js +8 -10
  55. package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
  56. package/build-module/button/index.native.js +8 -6
  57. package/build-module/button/index.native.js.map +1 -1
  58. package/build-module/color-palette/index.js +2 -2
  59. package/build-module/color-palette/index.js.map +1 -1
  60. package/build-module/focal-point-picker/index.native.js +6 -5
  61. package/build-module/focal-point-picker/index.native.js.map +1 -1
  62. package/build-module/form-token-field/styles.js +3 -2
  63. package/build-module/form-token-field/styles.js.map +1 -1
  64. package/build-module/item-group/item/hook.js +1 -1
  65. package/build-module/item-group/item/hook.js.map +1 -1
  66. package/build-module/item-group/styles.js +13 -11
  67. package/build-module/item-group/styles.js.map +1 -1
  68. package/build-module/menu-items-choice/index.js +1 -0
  69. package/build-module/menu-items-choice/index.js.map +1 -1
  70. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js +3 -1
  71. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js.map +1 -1
  72. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +43 -41
  73. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
  74. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +14 -20
  75. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  76. package/build-module/mobile/bottom-sheet/index.native.js +3 -1
  77. package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
  78. package/build-module/mobile/image/index.native.js +4 -3
  79. package/build-module/mobile/image/index.native.js.map +1 -1
  80. package/build-module/mobile/link-picker/link-picker-results.native.js +2 -1
  81. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  82. package/build-module/mobile/segmented-control/index.native.js +7 -7
  83. package/build-module/mobile/segmented-control/index.native.js.map +1 -1
  84. package/build-module/modal/index.js +14 -1
  85. package/build-module/modal/index.js.map +1 -1
  86. package/build-module/navigator/navigator-provider/component.js +18 -10
  87. package/build-module/navigator/navigator-provider/component.js.map +1 -1
  88. package/build-module/private-apis.js +3 -1
  89. package/build-module/private-apis.js.map +1 -1
  90. package/build-module/progress-bar/index.js +41 -0
  91. package/build-module/progress-bar/index.js.map +1 -0
  92. package/build-module/progress-bar/styles.js +61 -0
  93. package/build-module/progress-bar/styles.js.map +1 -0
  94. package/build-module/progress-bar/types.js +2 -0
  95. package/build-module/progress-bar/types.js.map +1 -0
  96. package/build-module/query-controls/index.js +1 -0
  97. package/build-module/query-controls/index.js.map +1 -1
  98. package/build-module/query-controls/index.native.js +1 -0
  99. package/build-module/query-controls/index.native.js.map +1 -1
  100. package/build-module/tab-panel/index.js +88 -59
  101. package/build-module/tab-panel/index.js.map +1 -1
  102. package/build-module/text-control/index.js +2 -2
  103. package/build-module/text-control/index.js.map +1 -1
  104. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js +11 -7
  105. package/build-module/toolbar/toolbar-group/toolbar-group-container.native.js.map +1 -1
  106. package/build-style/style-rtl.css +3 -0
  107. package/build-style/style.css +3 -0
  108. package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
  109. package/build-types/form-token-field/styles.d.ts.map +1 -1
  110. package/build-types/item-group/item/hook.d.ts.map +1 -1
  111. package/build-types/item-group/stories/index.d.ts.map +1 -1
  112. package/build-types/item-group/styles.d.ts +1 -1
  113. package/build-types/item-group/styles.d.ts.map +1 -1
  114. package/build-types/menu-items-choice/index.d.ts.map +1 -1
  115. package/build-types/menu-items-choice/types.d.ts +5 -0
  116. package/build-types/menu-items-choice/types.d.ts.map +1 -1
  117. package/build-types/modal/index.d.ts.map +1 -1
  118. package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
  119. package/build-types/navigator/types.d.ts +3 -1
  120. package/build-types/navigator/types.d.ts.map +1 -1
  121. package/build-types/private-apis.d.ts.map +1 -1
  122. package/build-types/progress-bar/index.d.ts +5 -0
  123. package/build-types/progress-bar/index.d.ts.map +1 -0
  124. package/build-types/progress-bar/stories/index.d.ts +12 -0
  125. package/build-types/progress-bar/stories/index.d.ts.map +1 -0
  126. package/build-types/progress-bar/styles.d.ts +18 -0
  127. package/build-types/progress-bar/styles.d.ts.map +1 -0
  128. package/build-types/progress-bar/test/index.d.ts +2 -0
  129. package/build-types/progress-bar/test/index.d.ts.map +1 -0
  130. package/build-types/progress-bar/types.d.ts +11 -0
  131. package/build-types/progress-bar/types.d.ts.map +1 -0
  132. package/build-types/query-controls/index.d.ts.map +1 -1
  133. package/build-types/tab-panel/index.d.ts.map +1 -1
  134. package/build-types/tab-panel/stories/index.d.ts +1 -0
  135. package/build-types/tab-panel/stories/index.d.ts.map +1 -1
  136. package/build-types/tab-panel/types.d.ts +1 -9
  137. package/build-types/tab-panel/types.d.ts.map +1 -1
  138. package/build-types/text-control/test/text-control.d.ts +2 -0
  139. package/build-types/text-control/test/text-control.d.ts.map +1 -0
  140. package/package.json +22 -22
  141. package/src/border-control/border-control-dropdown/component.tsx +7 -11
  142. package/src/border-control/test/index.js +6 -6
  143. package/src/button/index.native.js +9 -3
  144. package/src/button/style.native.scss +9 -0
  145. package/src/color-palette/index.tsx +2 -2
  146. package/src/color-palette/test/__snapshots__/index.tsx.snap +1 -1
  147. package/src/color-palette/test/index.tsx +1 -5
  148. package/src/draggable/test/index.native.js +4 -0
  149. package/src/focal-point-picker/index.native.js +6 -5
  150. package/src/form-token-field/styles.ts +2 -0
  151. package/src/item-group/item/hook.ts +2 -1
  152. package/src/item-group/stories/index.tsx +8 -3
  153. package/src/item-group/styles.ts +39 -28
  154. package/src/menu-item/README.md +7 -0
  155. package/src/menu-items-choice/index.tsx +1 -0
  156. package/src/menu-items-choice/types.ts +5 -0
  157. package/src/mobile/bottom-sheet/bottom-sheet-navigation/bottom-sheet-navigation-context.native.js +1 -1
  158. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +72 -53
  159. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +15 -21
  160. package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +165 -119
  161. package/src/mobile/bottom-sheet/index.native.js +2 -0
  162. package/src/mobile/image/index.native.js +8 -6
  163. package/src/mobile/image/style.native.scss +5 -1
  164. package/src/mobile/link-picker/link-picker-results.native.js +1 -1
  165. package/src/mobile/link-settings/test/edit.native.js +37 -23
  166. package/src/mobile/segmented-control/index.native.js +11 -11
  167. package/src/modal/index.tsx +16 -0
  168. package/src/modal/test/index.tsx +33 -0
  169. package/src/navigator/navigator-provider/component.tsx +30 -23
  170. package/src/navigator/types.ts +4 -1
  171. package/src/placeholder/style.scss +5 -0
  172. package/src/private-apis.ts +2 -0
  173. package/src/progress-bar/README.md +30 -0
  174. package/src/progress-bar/index.tsx +45 -0
  175. package/src/progress-bar/stories/index.tsx +33 -0
  176. package/src/progress-bar/styles.ts +67 -0
  177. package/src/progress-bar/test/index.tsx +79 -0
  178. package/src/progress-bar/types.ts +11 -0
  179. package/src/query-controls/index.native.js +1 -0
  180. package/src/query-controls/index.tsx +1 -0
  181. package/src/tab-panel/index.tsx +121 -84
  182. package/src/tab-panel/stories/index.tsx +6 -0
  183. package/src/tab-panel/test/index.tsx +128 -109
  184. package/src/tab-panel/types.ts +1 -10
  185. package/src/text-control/index.tsx +2 -2
  186. package/src/text-control/test/text-control.tsx +61 -0
  187. package/src/toolbar/toolbar-group/style.native.scss +2 -3
  188. package/src/toolbar/toolbar-group/toolbar-group-container.native.js +12 -17
  189. package/src/tooltip/README.md +1 -1
  190. package/tsconfig.tsbuildinfo +1 -1
@@ -39,20 +39,25 @@ Default.args = {
39
39
  children: (
40
40
  [
41
41
  {
42
- children: 'First item',
42
+ children: 'First button item',
43
43
  // eslint-disable-next-line no-alert
44
44
  onClick: () => alert( 'First item clicked' ),
45
45
  },
46
46
  {
47
- children: 'Second item',
47
+ children: 'Second button item',
48
48
  // eslint-disable-next-line no-alert
49
49
  onClick: () => alert( 'Second item clicked' ),
50
50
  },
51
51
  {
52
- children: 'Third item',
52
+ children: 'Third button item',
53
53
  // eslint-disable-next-line no-alert
54
54
  onClick: () => alert( 'Third item clicked' ),
55
55
  },
56
+ {
57
+ children: 'Anchor item',
58
+ as: 'a',
59
+ href: 'https://wordpress.org',
60
+ },
56
61
  ] as ItemProps[]
57
62
  ).map( mapPropsToItem ),
58
63
  };
@@ -6,34 +6,45 @@ import { css } from '@emotion/react';
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
- import { CONFIG, COLORS } from '../utils';
10
-
11
- export const unstyledButton = css`
12
- appearance: none;
13
- border: 1px solid transparent;
14
- cursor: pointer;
15
- background: none;
16
- text-align: start;
17
-
18
- svg,
19
- path {
20
- fill: currentColor;
21
- }
22
-
23
- &:hover {
24
- color: ${ COLORS.ui.theme };
25
- }
26
-
27
- &:focus-visible {
28
- box-shadow: 0 0 0 var( --wp-admin-border-width-focus )
29
- var(
30
- --wp-components-color-accent,
31
- var( --wp-admin-theme-color, ${ COLORS.ui.theme } )
32
- );
33
- // Windows high contrast mode.
34
- outline: 2px solid transparent;
35
- }
36
- `;
9
+ import { CONFIG, COLORS, font } from '../utils';
10
+
11
+ export const unstyledButton = ( as: 'a' | 'button' ) => {
12
+ return css`
13
+ font-size: ${ font( 'default.fontSize' ) };
14
+ font-family: inherit;
15
+ appearance: none;
16
+ border: 1px solid transparent;
17
+ cursor: pointer;
18
+ background: none;
19
+ text-align: start;
20
+ text-decoration: ${ as === 'a' ? 'none' : undefined };
21
+
22
+ svg,
23
+ path {
24
+ fill: currentColor;
25
+ }
26
+
27
+ &:hover {
28
+ color: ${ COLORS.ui.theme };
29
+ }
30
+
31
+ &:focus {
32
+ box-shadow: none;
33
+ outline: none;
34
+ }
35
+
36
+ &:focus-visible {
37
+ box-shadow: 0 0 0 var( --wp-admin-border-width-focus )
38
+ var(
39
+ --wp-components-color-accent,
40
+ var( --wp-admin-theme-color, ${ COLORS.ui.theme } )
41
+ );
42
+ // Windows high contrast mode.
43
+ outline: 2px solid transparent;
44
+ outline-offset: 0;
45
+ }
46
+ `;
47
+ };
37
48
 
38
49
  export const itemWrapper = css`
39
50
  width: 100%;
@@ -34,6 +34,13 @@ MenuItem supports the following props. Any additional props are passed through t
34
34
 
35
35
  Element to render as child of button.
36
36
 
37
+ ### `disabled`
38
+
39
+ - Type: `boolean`
40
+ - Required: No
41
+
42
+ Refer to documentation for [Button's `disabled` prop](/packages/components/src/button/README.md#disabled-boolean).
43
+
37
44
  ### `info`
38
45
 
39
46
  - Type: `string`
@@ -58,6 +58,7 @@ function MenuItemsChoice( {
58
58
  <MenuItem
59
59
  key={ item.value }
60
60
  role="menuitemradio"
61
+ disabled={ item.disabled }
61
62
  icon={ isSelected && check }
62
63
  info={ item.info }
63
64
  isSelected={ isSelected }
@@ -2,6 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import type { ShortcutProps } from '../shortcut/types';
5
+ import type { ButtonAsButtonProps } from '../button/types';
5
6
 
6
7
  export type MenuItemsChoiceProps = {
7
8
  /**
@@ -38,6 +39,10 @@ export type MenuItemChoice = {
38
39
  * Unique value for choice.
39
40
  */
40
41
  value: string;
42
+ /**
43
+ * Whether the menu item is disabled.
44
+ */
45
+ disabled?: ButtonAsButtonProps[ 'disabled' ];
41
46
  /**
42
47
  * Additional information which will be rendered below the given label.
43
48
  */
@@ -6,7 +6,7 @@ import { createContext } from '@wordpress/element';
6
6
  // Navigation context in BottomSheet is necessary for controlling the
7
7
  // height of navigation container.
8
8
  export const BottomSheetNavigationContext = createContext( {
9
- currentHeight: 1,
9
+ currentHeight: { value: 0 },
10
10
  setHeight: () => {},
11
11
  } );
12
12
 
@@ -1,15 +1,19 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { View, Easing } from 'react-native';
5
4
  import { NavigationContainer, DefaultTheme } from '@react-navigation/native';
6
5
  import { createStackNavigator } from '@react-navigation/stack';
6
+ import Animated, {
7
+ Easing,
8
+ useAnimatedStyle,
9
+ useSharedValue,
10
+ withTiming,
11
+ } from 'react-native-reanimated';
7
12
 
8
13
  /**
9
14
  * WordPress dependencies
10
15
  */
11
16
  import {
12
- useState,
13
17
  useContext,
14
18
  useMemo,
15
19
  useCallback,
@@ -23,11 +27,11 @@ import { usePreferredColorSchemeStyle } from '@wordpress/compose';
23
27
  /**
24
28
  * Internal dependencies
25
29
  */
26
- import { performLayoutAnimation } from '../../layout-animation';
27
30
  import {
28
31
  BottomSheetNavigationContext,
29
32
  BottomSheetNavigationProvider,
30
33
  } from './bottom-sheet-navigation-context';
34
+ import { BottomSheetContext } from '../bottom-sheet-context';
31
35
 
32
36
  import styles from './styles.scss';
33
37
 
@@ -57,7 +61,8 @@ const options = {
57
61
  cardStyleInterpolator: fadeConfig,
58
62
  };
59
63
 
60
- const ANIMATION_DURATION = 190;
64
+ const HEIGHT_ANIMATION_DURATION = 300;
65
+ const DEFAULT_HEIGHT = 1;
61
66
 
62
67
  function BottomSheetNavigationContainer( {
63
68
  children,
@@ -65,11 +70,14 @@ function BottomSheetNavigationContainer( {
65
70
  main,
66
71
  theme,
67
72
  style,
73
+ testID,
68
74
  } ) {
69
75
  const Stack = useRef( createStackNavigator() ).current;
70
- const context = useContext( BottomSheetNavigationContext );
71
- const [ currentHeight, setCurrentHeight ] = useState(
72
- context.currentHeight || 1
76
+ const navigationContext = useContext( BottomSheetNavigationContext );
77
+ const { maxHeight: sheetMaxHeight, isMaxHeightSet: isSheetMaxHeightSet } =
78
+ useContext( BottomSheetContext );
79
+ const currentHeight = useSharedValue(
80
+ navigationContext.currentHeight?.value || DEFAULT_HEIGHT
73
81
  );
74
82
 
75
83
  const backgroundStyle = usePreferredColorSchemeStyle(
@@ -77,47 +85,49 @@ function BottomSheetNavigationContainer( {
77
85
  styles.backgroundDark
78
86
  );
79
87
 
80
- const _theme = theme || {
81
- ...DefaultTheme,
82
- colors: {
83
- ...DefaultTheme.colors,
84
- background: backgroundStyle.backgroundColor,
85
- },
86
- };
88
+ const defaultTheme = useMemo(
89
+ () => ( {
90
+ ...DefaultTheme,
91
+ colors: {
92
+ ...DefaultTheme.colors,
93
+ background: backgroundStyle.backgroundColor,
94
+ },
95
+ } ),
96
+ [ backgroundStyle.backgroundColor ]
97
+ );
98
+ const _theme = theme || defaultTheme;
87
99
 
88
100
  const setHeight = useCallback(
89
101
  ( height ) => {
90
- // The screen is fullHeight.
91
102
  if (
92
- typeof height === 'string' &&
93
- typeof height !== typeof currentHeight
103
+ height > DEFAULT_HEIGHT &&
104
+ Math.round( height ) !== Math.round( currentHeight.value )
94
105
  ) {
95
- performLayoutAnimation( ANIMATION_DURATION );
96
- setCurrentHeight( height );
97
-
98
- return;
99
- }
100
-
101
- if (
102
- height > 1 &&
103
- Math.round( height ) !== Math.round( currentHeight )
104
- ) {
105
- if ( currentHeight === 1 ) {
106
- setCurrentHeight( height );
107
- } else if ( animate ) {
108
- performLayoutAnimation( ANIMATION_DURATION );
109
- setCurrentHeight( height );
106
+ // If max height is set in the bottom sheet, we clamp
107
+ // the new height using that value.
108
+ const newHeight = isSheetMaxHeightSet
109
+ ? Math.min( sheetMaxHeight, height )
110
+ : height;
111
+ const shouldAnimate =
112
+ animate && currentHeight.value !== DEFAULT_HEIGHT;
113
+
114
+ if ( shouldAnimate ) {
115
+ currentHeight.value = withTiming( newHeight, {
116
+ duration: HEIGHT_ANIMATION_DURATION,
117
+ easing: Easing.out( Easing.cubic ),
118
+ } );
110
119
  } else {
111
- setCurrentHeight( height );
120
+ currentHeight.value = newHeight;
112
121
  }
113
122
  }
114
123
  },
115
- // Disable reason: deferring this refactor to the native team.
116
- // see https://github.com/WordPress/gutenberg/pull/41166
117
- // eslint-disable-next-line react-hooks/exhaustive-deps
118
- [ currentHeight ]
124
+ [ animate, currentHeight, isSheetMaxHeightSet, sheetMaxHeight ]
119
125
  );
120
126
 
127
+ const animatedStyles = useAnimatedStyle( () => ( {
128
+ height: currentHeight.value,
129
+ } ) );
130
+
121
131
  const screens = useMemo( () => {
122
132
  return Children.map( children, ( child ) => {
123
133
  let screen = child;
@@ -136,38 +146,47 @@ function BottomSheetNavigationContainer( {
136
146
  />
137
147
  );
138
148
  } );
139
- // Disable reason: deferring this refactor to the native team.
140
- // see https://github.com/WordPress/gutenberg/pull/41166
141
- // eslint-disable-next-line react-hooks/exhaustive-deps
142
- }, [ children ] );
149
+ }, [ children, main ] );
143
150
 
144
151
  return useMemo( () => {
145
152
  return (
146
- <View style={ [ style, { height: currentHeight } ] }>
153
+ <Animated.View
154
+ style={ [ style, animatedStyles ] }
155
+ testID={ testID }
156
+ >
147
157
  <BottomSheetNavigationProvider
148
- value={ {
149
- setHeight,
150
- currentHeight,
151
- } }
158
+ value={ { setHeight, currentHeight } }
152
159
  >
153
160
  { main ? (
154
161
  <NavigationContainer theme={ _theme }>
155
- <Stack.Navigator screenOptions={ options }>
162
+ <Stack.Navigator
163
+ screenOptions={ options }
164
+ detachInactiveScreens={ false }
165
+ >
156
166
  { screens }
157
167
  </Stack.Navigator>
158
168
  </NavigationContainer>
159
169
  ) : (
160
- <Stack.Navigator screenOptions={ options }>
170
+ <Stack.Navigator
171
+ screenOptions={ options }
172
+ detachInactiveScreens={ false }
173
+ >
161
174
  { screens }
162
175
  </Stack.Navigator>
163
176
  ) }
164
177
  </BottomSheetNavigationProvider>
165
- </View>
178
+ </Animated.View>
166
179
  );
167
- // Disable reason: deferring this refactor to the native team.
168
- // see https://github.com/WordPress/gutenberg/pull/41166
169
- // eslint-disable-next-line react-hooks/exhaustive-deps
170
- }, [ currentHeight, _theme ] );
180
+ }, [
181
+ _theme,
182
+ animatedStyles,
183
+ currentHeight,
184
+ main,
185
+ screens,
186
+ setHeight,
187
+ style,
188
+ testID,
189
+ ] );
171
190
  }
172
191
 
173
192
  export default BottomSheetNavigationContainer;
@@ -6,13 +6,17 @@ import {
6
6
  useNavigation,
7
7
  useFocusEffect,
8
8
  } from '@react-navigation/native';
9
- import { View, ScrollView, TouchableHighlight } from 'react-native';
9
+ import {
10
+ ScrollView,
11
+ TouchableHighlight,
12
+ useWindowDimensions,
13
+ View,
14
+ } from 'react-native';
10
15
 
11
16
  /**
12
17
  * WordPress dependencies
13
18
  */
14
19
  import { BottomSheetContext } from '@wordpress/components';
15
- import { debounce } from '@wordpress/compose';
16
20
  import { useRef, useCallback, useContext, useMemo } from '@wordpress/element';
17
21
 
18
22
  /**
@@ -29,7 +33,7 @@ const BottomSheetNavigationScreen = ( {
29
33
  name,
30
34
  } ) => {
31
35
  const navigation = useNavigation();
32
- const heightRef = useRef( { maxHeight: 0 } );
36
+ const maxHeight = useRef( 0 );
33
37
  const isFocused = useIsFocused();
34
38
  const {
35
39
  onHandleHardwareButtonPress,
@@ -38,16 +42,10 @@ const BottomSheetNavigationScreen = ( {
38
42
  listProps,
39
43
  safeAreaBottomInset,
40
44
  } = useContext( BottomSheetContext );
45
+ const { height: windowHeight } = useWindowDimensions();
41
46
 
42
47
  const { setHeight } = useContext( BottomSheetNavigationContext );
43
48
 
44
- // Disable reason: deferring this refactor to the native team.
45
- // see https://github.com/WordPress/gutenberg/pull/41166
46
- // eslint-disable-next-line react-hooks/exhaustive-deps
47
- const setHeightDebounce = useCallback( debounce( setHeight, 10 ), [
48
- setHeight,
49
- ] );
50
-
51
49
  useFocusEffect(
52
50
  useCallback( () => {
53
51
  onHandleHardwareButtonPress( () => {
@@ -81,17 +79,14 @@ const BottomSheetNavigationScreen = ( {
81
79
  useFocusEffect(
82
80
  useCallback( () => {
83
81
  if ( fullScreen ) {
84
- setHeight( '100%' );
82
+ setHeight( windowHeight );
85
83
  setIsFullScreen( true );
86
- } else if ( heightRef.current.maxHeight !== 0 ) {
84
+ } else if ( maxHeight.current !== 0 ) {
87
85
  setIsFullScreen( false );
88
- setHeight( heightRef.current.maxHeight );
86
+ setHeight( maxHeight.current );
89
87
  }
90
88
  return () => {};
91
- // Disable reason: deferring this refactor to the native team.
92
- // see https://github.com/WordPress/gutenberg/pull/41166
93
- // eslint-disable-next-line react-hooks/exhaustive-deps
94
- }, [ setHeight ] )
89
+ }, [ fullScreen, setHeight, setIsFullScreen, windowHeight ] )
95
90
  );
96
91
 
97
92
  const onLayout = ( { nativeEvent } ) => {
@@ -99,10 +94,9 @@ const BottomSheetNavigationScreen = ( {
99
94
  return;
100
95
  }
101
96
  const { height } = nativeEvent.layout;
102
-
103
- if ( heightRef.current.maxHeight !== height && isFocused ) {
104
- heightRef.current.maxHeight = height;
105
- setHeightDebounce( height );
97
+ if ( maxHeight.current !== height && isFocused ) {
98
+ maxHeight.current = height;
99
+ setHeight( height );
106
100
  }
107
101
  };
108
102