@mpxjs/webpack-plugin 2.10.14-beta.11 → 2.10.14-beta.13

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.
@@ -12,6 +12,7 @@ export type KeyboardAvoidContextValue = MutableRefObject<{
12
12
  adjustPosition: boolean
13
13
  keyboardHeight?: number
14
14
  onKeyboardShow?: () => void
15
+ readyToShow?: boolean
15
16
  } | null>
16
17
 
17
18
  export interface GroupValue {
@@ -9,6 +9,7 @@ export type KeyboardAvoidContextValue = MutableRefObject<{
9
9
  adjustPosition: boolean;
10
10
  keyboardHeight?: number;
11
11
  onKeyboardShow?: () => void;
12
+ readyToShow?: boolean;
12
13
  } | null>;
13
14
  export interface GroupValue {
14
15
  [key: string]: {
@@ -144,7 +144,7 @@ const Input = forwardRef((props, ref) => {
144
144
  };
145
145
  const setKeyboardAvoidContext = () => {
146
146
  if (keyboardAvoid) {
147
- keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition };
147
+ keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition, readyToShow: true };
148
148
  }
149
149
  };
150
150
  const onTouchStart = () => {
@@ -28,8 +28,9 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
28
28
  timerRef.current && clearTimeout(timerRef.current);
29
29
  if (keyboardAvoid?.current) {
30
30
  const inputRef = keyboardAvoid.current.ref?.current;
31
- if (inputRef && inputRef.isFocused()) {
31
+ if (inputRef && inputRef.isFocused() && !keyboardAvoid.current.readyToShow) {
32
32
  // 修复 Android 点击键盘收起按钮时当前 input 没触发失焦的问题
33
+ // keyboardAvoid.current.readyToShow = true 表示聚焦到了新的输入框,不需要手动触发失焦
33
34
  inputRef.blur();
34
35
  }
35
36
  if (!keyboardAvoid.current.onKeyboardShow) {
@@ -48,6 +49,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
48
49
  useEffect(() => {
49
50
  let subscriptions = [];
50
51
  function keybaordAvoding(evt, ios = false) {
52
+ if (keyboardAvoid?.current?.readyToShow) {
53
+ // 重置标记位
54
+ keyboardAvoid.current.readyToShow = false;
55
+ }
51
56
  if (!keyboardAvoid?.current || isShow.current) {
52
57
  return;
53
58
  }
@@ -203,7 +203,7 @@ function backgroundSize(imageProps, preImageInfo, imageSize, layoutInfo) {
203
203
  else { // 数值类型 ImageStyle
204
204
  // 数值类型设置为 stretch
205
205
  imageProps.resizeMode = 'stretch';
206
- if (type === 'linear' && (!layoutWidth || !layoutHeight)) {
206
+ if (type === 'linear' && (!layoutWidth || !layoutHeight) && isNeedLayout(preImageInfo)) {
207
207
  // ios 上 linear 组件只要重新触发渲染,在渲染过程中外层容器 width 或者 height 被设置为 0,通过设置 % 的方式会渲染不出来,即使后面再更新为正常宽高也渲染不出来
208
208
  // 所以 hack 手动先将 linear 宽高也设置为 0,后面再更新为正确的数值或 %。
209
209
  dimensions = {
@@ -212,6 +212,7 @@ function backgroundSize(imageProps, preImageInfo, imageSize, layoutInfo) {
212
212
  };
213
213
  }
214
214
  else {
215
+ // background-size 手动设置具体值,不会触发 onLayout,需要走这里的逻辑
215
216
  dimensions = {
216
217
  width: isPercent(width) ? width : +width,
217
218
  height: isPercent(height) ? height : +height
@@ -283,7 +283,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
283
283
 
284
284
  const setKeyboardAvoidContext = () => {
285
285
  if (keyboardAvoid) {
286
- keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition }
286
+ keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition, readyToShow: true }
287
287
  }
288
288
  }
289
289
 
@@ -41,8 +41,9 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
41
41
 
42
42
  if (keyboardAvoid?.current) {
43
43
  const inputRef = keyboardAvoid.current.ref?.current
44
- if (inputRef && inputRef.isFocused()) {
44
+ if (inputRef && inputRef.isFocused() && !keyboardAvoid.current.readyToShow) {
45
45
  // 修复 Android 点击键盘收起按钮时当前 input 没触发失焦的问题
46
+ // keyboardAvoid.current.readyToShow = true 表示聚焦到了新的输入框,不需要手动触发失焦
46
47
  inputRef.blur()
47
48
  }
48
49
  if (!keyboardAvoid.current.onKeyboardShow) {
@@ -65,6 +66,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
65
66
  let subscriptions: EmitterSubscription[] = []
66
67
 
67
68
  function keybaordAvoding(evt: any, ios = false) {
69
+ if (keyboardAvoid?.current?.readyToShow) {
70
+ // 重置标记位
71
+ keyboardAvoid.current.readyToShow = false
72
+ }
68
73
  if (!keyboardAvoid?.current || isShow.current) {
69
74
  return
70
75
  }
@@ -287,7 +287,7 @@ function backgroundSize (imageProps: ImageProps, preImageInfo: PreImageInfo, ima
287
287
  } else { // 数值类型 ImageStyle
288
288
  // 数值类型设置为 stretch
289
289
  imageProps.resizeMode = 'stretch'
290
- if (type === 'linear' && (!layoutWidth || !layoutHeight)) {
290
+ if (type === 'linear' && (!layoutWidth || !layoutHeight) && isNeedLayout(preImageInfo)) {
291
291
  // ios 上 linear 组件只要重新触发渲染,在渲染过程中外层容器 width 或者 height 被设置为 0,通过设置 % 的方式会渲染不出来,即使后面再更新为正常宽高也渲染不出来
292
292
  // 所以 hack 手动先将 linear 宽高也设置为 0,后面再更新为正确的数值或 %。
293
293
  dimensions = {
@@ -295,6 +295,7 @@ function backgroundSize (imageProps: ImageProps, preImageInfo: PreImageInfo, ima
295
295
  height: 0
296
296
  } as { width: NumberVal, height: NumberVal }
297
297
  } else {
298
+ // background-size 手动设置具体值,不会触发 onLayout,需要走这里的逻辑
298
299
  dimensions = {
299
300
  width: isPercent(width) ? width : +width,
300
301
  height: isPercent(height) ? height : +height
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.14-beta.11",
3
+ "version": "2.10.14-beta.13",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"