diff --git a/src/_common b/src/_common index 4bdf9ced2d..c2be429ce8 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 4bdf9ced2d0b1c3aaf88c035424ef2230d71f396 +Subproject commit c2be429ce8b4f75c8d166a9ce4d6a3c69e01e2d3 diff --git a/src/anchor/_example-ts/custom-scroll.vue b/src/anchor/_example-ts/custom-scroll.vue new file mode 100644 index 0000000000..b74c09cc18 --- /dev/null +++ b/src/anchor/_example-ts/custom-scroll.vue @@ -0,0 +1,19 @@ + + diff --git a/src/anchor/_example/custom-scroll.vue b/src/anchor/_example/custom-scroll.vue new file mode 100644 index 0000000000..60a52e541f --- /dev/null +++ b/src/anchor/_example/custom-scroll.vue @@ -0,0 +1,19 @@ + + diff --git a/src/anchor/anchor-item-props.ts b/src/anchor/anchor-item-props.ts index 12f20eb310..b5d213722a 100644 --- a/src/anchor/anchor-item-props.ts +++ b/src/anchor/anchor-item-props.ts @@ -28,4 +28,9 @@ export default { type: [String, Function] as PropType, default: '', }, + /** 自定义滚动效果,为true时点击锚点链接后不会使用js动画平滑滚动到锚点目标元素 */ + customScroll: { + type: Boolean, + default: false, + }, }; diff --git a/src/anchor/anchor-item.tsx b/src/anchor/anchor-item.tsx index f04d676231..ce6b3261bc 100644 --- a/src/anchor/anchor-item.tsx +++ b/src/anchor/anchor-item.tsx @@ -37,7 +37,7 @@ export default defineComponent({ }; const handleClick = (e: MouseEvent) => { const { href, title } = props; - anchor.handleScrollTo(href); + if (!props.customScroll) anchor.handleScrollTo(href); anchor.handleLinkClick({ href, title: isString(title) ? title : undefined, e }); }; const renderTitle = () => { diff --git a/src/anchor/anchor.en-US.md b/src/anchor/anchor.en-US.md index 44ea48592d..f17aff4d41 100644 --- a/src/anchor/anchor.en-US.md +++ b/src/anchor/anchor.en-US.md @@ -29,6 +29,7 @@ name | type | default | description | required href | String | - | required | Y target | String | _self | options:_self/_blank/_parent/_top | N title | String / Slot / Function | '' | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N +customScroll | Boolean | false | Custom scroll effect: When set to true, clicking on an anchor link will not use JavaScript animation to smoothly scroll to the anchor target element. ### AnchorTarget Props diff --git a/src/anchor/anchor.md b/src/anchor/anchor.md index 52f3c4258e..8bf8a8f1e7 100644 --- a/src/anchor/anchor.md +++ b/src/anchor/anchor.md @@ -28,6 +28,7 @@ click | `(link: { href: string; title: string; e: MouseEvent })` | 锚点被点 href | String | - | 必需。锚点链接, 如果是 hash 模式需要加上当前 path | Y target | String | _self | 锚点文本。可选项:_self/_blank/_parent/_top | N title | String / Slot / Function | '' | 锚点文本。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/src/common.ts) | N +customScroll | Boolean | false | 自定义滚动效果,为true时点击锚点链接后不会使用js动画平滑滚动到锚点目标元素 ### AnchorTarget Props diff --git a/src/anchor/type.ts b/src/anchor/type.ts index 2c9b066a93..75a5cf5b44 100644 --- a/src/anchor/type.ts +++ b/src/anchor/type.ts @@ -76,4 +76,9 @@ export interface TdAnchorItemProps { * @default '' */ title?: string | TNode; + /** + * 自定义滚动效果,为true时点击锚点链接后不会使用js动画平滑滚动到锚点目标元素 + * @default false + */ + customScroll?: boolean; } diff --git a/src/date-picker/hooks/useTableData.tsx b/src/date-picker/hooks/useTableData.tsx index b1ba9958a3..ca3245d01f 100644 --- a/src/date-picker/hooks/useTableData.tsx +++ b/src/date-picker/hooks/useTableData.tsx @@ -38,5 +38,7 @@ export default function useTableData(props: any) { hoverEnd: props.hoverEnd, type: props.mode, isRange: props.isRange, + value: props.value, + multiple: props.multiple, }); } diff --git a/test/unit/snap/__snapshots__/csr.test.js.snap b/test/unit/snap/__snapshots__/csr.test.js.snap index d7f4b9ce80..563ebbd294 100644 --- a/test/unit/snap/__snapshots__/csr.test.js.snap +++ b/test/unit/snap/__snapshots__/csr.test.js.snap @@ -1399,6 +1399,108 @@ exports[`csr snapshot test > csr test ./src/anchor/_example/cursor.vue 1`] = ` `; +exports[`csr snapshot test > csr test ./src/anchor/_example/custom-scroll.vue 1`] = ` +
+ +`; + exports[`csr snapshot test > csr test ./src/anchor/_example/large.vue 1`] = `
ssr test ./src/anchor/_example/container.vue 1`] = exports[`ssr snapshot test > ssr test ./src/anchor/_example/cursor.vue 1`] = `""`; +exports[`ssr snapshot test > ssr test ./src/anchor/_example/custom-scroll.vue 1`] = `""`; + exports[`ssr snapshot test > ssr test ./src/anchor/_example/large.vue 1`] = `""`; exports[`ssr snapshot test > ssr test ./src/anchor/_example/multiple.vue 1`] = `""`;