Repository: ant-design/ant-design-mobile
Pull request #6284 (2023-08-04 06:47:45)

enhance: passive and preventDefault coexist repair
issue #6282
加的判断是这个 preventDefault 的
https://github.com/ant-design/ant-design-mobile/blob/master/src/utils/use-lock-scroll.ts#L68

下面这个 preventDefault 应该不用加吧？跟这个 PR 有关 #5738
https://github.com/ant-design/ant-design-mobile/blob/master/src/utils/use-lock-scroll.ts#L48

github-actions[bot]: PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-6284.surge.sh
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) Report
Patch coverage: **`85.71%`** and project coverage change: **`-0.02%`** :warning:
> Comparison is base [(`317c116`)](https://app.codecov.io/gh/ant-design/ant-design-mobile/commit/317c1163e8d32e7376f8967f31a5bbc3c8695406?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) 90.91% compared to head [(`e20ef21`)](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) 90.90%.
> Report is 1 commits behind head on master.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #6284      +/-   ##
==========================================
- Coverage   90.91%   90.90%   -0.02%     
==========================================
  Files         305      306       +1     
  Lines        6605     6595      -10     
  Branches     1633     1633              
==========================================
- Hits         6005     5995      -10     
- Misses        555      556       +1     
+ Partials       45       44       -1     
```


| [Files Changed](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) | Coverage Δ | |
|---|---|---|
| [src/locales/base.ts](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2xvY2FsZXMvYmFzZS50cw==) | `100.00% <ø> (ø)` | |
| [src/locales/da-DK.ts](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2xvY2FsZXMvZGEtREsudHM=) | `100.00% <ø> (ø)` | |
| [src/locales/es-ES.ts](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2xvY2FsZXMvZXMtRVMudHM=) | `100.00% <ø> (ø)` | |
| [src/locales/fa-IR.ts](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2xvY2FsZXMvZmEtSVIudHM=) | `100.00% <ø> (ø)` | |
| [src/locales/fr-FR.ts](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2xvY2FsZXMvZnItRlIudHM=) | `100.00% <ø> (ø)` | |
| [src/locales/id-ID.ts](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2xvY2FsZXMvaWQtSUQudHM=) | `100.00% <ø> (ø)` | |
| [src/locales/it-IT.ts](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2xvY2FsZXMvaXQtSVQudHM=) | `100.00% <ø> (ø)` | |
| [src/locales/ja-JP.ts](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2xvY2FsZXMvamEtSlAudHM=) | `100.00% <ø> (ø)` | |
| [src/locales/kk-KZ.ts](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2xvY2FsZXMva2stS1oudHM=) | `100.00% <ø> (ø)` | |
| [src/locales/ko-KR.ts](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2xvY2FsZXMva28tS1IudHM=) | `100.00% <ø> (ø)` | |
| ... and [9 more](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) | |


</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6284?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design).


Patch:
diff --git a/src/components/rate/rate.tsx b/src/components/rate/rate.tsx
index 47a52610f..a175f1e6d 100644
--- a/src/components/rate/rate.tsx
+++ b/src/components/rate/rate.tsx
@@ -18,7 +18,12 @@ export type RateProps = {
   readOnly?: boolean
   value?: number
   onChange?: (value: number) => void
-} & NativeProps<'--star-size' | '--active-color' | '--inactive-color'>
+} & NativeProps<
+  | '--star-size'
+  | '--active-color'
+  | '--inactive-color'
+  | '--inactive-color-half'
+>
 
 const defaultProps = {
   count: 5,
diff --git a/src/utils/use-lock-scroll.ts b/src/utils/use-lock-scroll.ts
index 9c5e95ea1..97301d308 100644
--- a/src/utils/use-lock-scroll.ts
+++ b/src/utils/use-lock-scroll.ts
@@ -64,7 +64,8 @@ export function useLockScroll(
       touch.isVertical() &&
       !(parseInt(status, 2) & parseInt(direction, 2))
     ) {
-      if (event.cancelable) {
+      if (event.cancelable && supportsPassive) {
+        // https://github.com/ant-design/ant-design-mobile/issues/6282
         event.preventDefault()
       }
     }


Test patch:
diff --git a/src/utils/tests/use-lock-scroll.test.tsx b/src/utils/tests/use-lock-scroll.test.tsx
new file mode 100644
index 000000000..5529a3b59
--- /dev/null
+++ b/src/utils/tests/use-lock-scroll.test.tsx
@@ -0,0 +1,48 @@
+import React, { useRef } from 'react'
+import { render, fireEvent } from 'testing'
+import { useLockScroll } from '../use-lock-scroll'
+
+describe('useLockScroll', () => {
+  test('onTouchMove', async () => {
+    const handleTouch = jest.fn()
+    const TestComponent = () => {
+      const divRef = useRef<HTMLDivElement>(null)
+
+      useLockScroll(divRef, true)
+
+      return (
+        <div
+          ref={divRef}
+          data-testid='lock'
+          style={{
+            height: 200,
+            overflow: 'scroll',
+            cursor: 'grab',
+            touchAction: 'none',
+          }}
+          onTouchMove={handleTouch}
+        >
+          {new Array(10).fill({}).map((_, i) => (
+            <h1 key={i}> Test component {i}</h1>
+          ))}
+        </div>
+      )
+    }
+
+    const { getByTestId } = render(<TestComponent />)
+
+    const testEl = getByTestId('lock')
+
+    fireEvent.touchStart(testEl, {
+      touches: [{ clientX: 0, clientY: 0 }],
+    })
+    fireEvent.touchMove(testEl, {
+      touches: [{ clientX: 0, clientY: 200 }],
+    })
+    fireEvent.touchEnd(testEl, {
+      touches: [{ clientX: 0, clientY: 400 }],
+    })
+
+    expect(handleTouch).toHaveBeenCalled()
+  })
+})