Repository: ant-design/ant-design-mobile
Pull request #6304 (2023-08-10 06:55:17)

chore: pickview use classPrefix

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6304?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) Report
Patch and project coverage have no change.
> Comparison is base [(`46ffd90`)](https://app.codecov.io/gh/ant-design/ant-design-mobile/commit/46ffd908a2bbb65a1fbdf4d57c041e2cda982bab?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) 91.56% compared to head [(`e5eca49`)](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6304?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) 91.56%.

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


```diff
@@           Coverage Diff           @@
##           master    #6304   +/-   ##
=======================================
  Coverage   91.56%   91.56%           
=======================================
  Files         306      306           
  Lines        6591     6591           
  Branches     1627     1627           
=======================================
  Hits         6035     6035           
  Misses        521      521           
  Partials       35       35           
```


| [Files Changed](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6304?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design) | Coverage Δ | |
|---|---|---|
| [src/components/picker-view/wheel.tsx](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6304?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=ant-design#diff-c3JjL2NvbXBvbmVudHMvcGlja2VyLXZpZXcvd2hlZWwudHN4) | `79.85% <ø> (ø)` | |


</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/ant-design/ant-design-mobile/pull/6304?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).

github-actions[bot]: PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-6304.surge.sh

Patch:
diff --git a/src/components/center-popup/center-popup.tsx b/src/components/center-popup/center-popup.tsx
index 7277a389c..94a1ac63d 100644
--- a/src/components/center-popup/center-popup.tsx
+++ b/src/components/center-popup/center-popup.tsx
@@ -16,6 +16,8 @@ import {
   PopupBaseProps,
 } from '../popup/popup-base-props'
 
+const classPrefix = 'adm-center-popup'
+
 export type CenterPopupProps = PopupBaseProps &
   PropsWithChildren<{
     // These props currently are only used internally. They are not exported to users:
@@ -72,7 +74,7 @@ export const CenterPopup: FC<CenterPopupProps> = p => {
 
   const body = (
     <div
-      className={classNames('adm-center-popup-body', props.bodyClassName)}
+      className={classNames(`${classPrefix}-body`, props.bodyClassName)}
       style={props.bodyStyle}
     >
       {props.children}
@@ -84,7 +86,7 @@ export const CenterPopup: FC<CenterPopupProps> = p => {
     withNativeProps(
       props,
       <div
-        className='adm-center-popup'
+        className={classPrefix}
         style={{
           display: active ? undefined : 'none',
           pointerEvents: active ? undefined : 'none',
@@ -102,13 +104,13 @@ export const CenterPopup: FC<CenterPopupProps> = p => {
               }
             }}
             style={props.maskStyle}
-            className={classNames('adm-center-popup-mask', props.maskClassName)}
+            className={classNames(`${classPrefix}-mask`, props.maskClassName)}
             disableBodyScroll={false}
             stopPropagation={props.stopPropagation}
           />
         )}
         <div
-          className='adm-center-popup-wrap'
+          className={`${classPrefix}-wrap`}
           role={props.role}
           aria-label={props['aria-label']}
         >
@@ -116,7 +118,7 @@ export const CenterPopup: FC<CenterPopupProps> = p => {
             {props.showCloseButton && (
               <a
                 className={classNames(
-                  'adm-center-popup-close',
+                  `${classPrefix}-close`,
                   'adm-plain-anchor'
                 )}
                 onClick={() => {
diff --git a/src/components/error-block/create-error-block.tsx b/src/components/error-block/create-error-block.tsx
index 6b920c241..ef873e423 100644
--- a/src/components/error-block/create-error-block.tsx
+++ b/src/components/error-block/create-error-block.tsx
@@ -30,9 +30,10 @@ export function createErrorBlock(imageRecord: ImageRecord) {
     const props = mergeProps(defaultProps, p)
     const { locale } = useConfig()
     const contentPack = locale.ErrorBlock[props.status]
-    const des =
+    const desc =
       'description' in props ? props.description : contentPack.description
     const title = 'title' in props ? props.title : contentPack.title
+
     const image: ReactNode = props.image ?? imageRecord[props.status]
     const imageNode =
       typeof image === 'string' ? (
@@ -50,11 +51,12 @@ export function createErrorBlock(imageRecord: ImageRecord) {
       >
         <div className={`${classPrefix}-image`}>{imageNode}</div>
         <div className={`${classPrefix}-description`}>
-          {title && (
+          {![undefined, null].includes(title as null) && (
             <div className={`${classPrefix}-description-title`}>{title}</div>
           )}
-          {des && (
-            <div className={`${classPrefix}-description-subtitle`}>{des}</div>
+
+          {![undefined, null].includes(desc as null) && (
+            <div className={`${classPrefix}-description-subtitle`}>{desc}</div>
           )}
         </div>
 
diff --git a/src/components/picker-view/wheel.tsx b/src/components/picker-view/wheel.tsx
index 6c8e95874..26afc7e96 100644
--- a/src/components/picker-view/wheel.tsx
+++ b/src/components/picker-view/wheel.tsx
@@ -217,9 +217,9 @@ export const Wheel = memo<Props>(
       const previous = column[previousIndex]
       const next = column[nextIndex]
       return (
-        <div className='adm-picker-view-column-accessible'>
+        <div className={`${classPrefix}-column-accessible`}>
           <div
-            className='adm-picker-view-column-accessible-current'
+            className={`${classPrefix}-column-accessible-current`}
             role='button'
             aria-label={
               current ? `当前选择的是：${current.label}` : '当前未选择'
@@ -228,7 +228,7 @@ export const Wheel = memo<Props>(
             -
           </div>
           <div
-            className='adm-picker-view-column-accessible-button'
+            className={`${classPrefix}-column-accessible-button`}
             onClick={() => {
               if (!previous) return
               scrollSelect(previousIndex)
@@ -241,7 +241,7 @@ export const Wheel = memo<Props>(
             -
           </div>
           <div
-            className='adm-picker-view-column-accessible-button'
+            className={`${classPrefix}-column-accessible-button`}
             onClick={() => {
               if (!next) return
               scrollSelect(nextIndex)


Test patch:
diff --git a/src/components/error-block/tests/error-block.test.tsx b/src/components/error-block/tests/error-block.test.tsx
index 350e7f32b..c59376e20 100644
--- a/src/components/error-block/tests/error-block.test.tsx
+++ b/src/components/error-block/tests/error-block.test.tsx
@@ -60,4 +60,24 @@ describe('ErrorBlock', () => {
 
     expect(container).toMatchSnapshot()
   })
+  test('renders when description and title', async () => {
+    const title = 0
+    const description = 0
+
+    const { container } = render(
+      <ErrorBlock title={title} description={description} />
+    )
+
+    const titleElement = container.querySelector(
+      `.${classPrefix}-description-title`
+    )
+    expect(titleElement).toBeInTheDocument()
+    expect(titleElement?.textContent).toBe(title + '')
+
+    const descElement = container.querySelector(
+      `.${classPrefix}-description-subtitle`
+    )
+    expect(descElement).toBeInTheDocument()
+    expect(descElement?.textContent).toBe(description + '')
+  })
 })