Skip to content

Commit 7f9c610

Browse files
luckymore张宁宁
and
张宁宁
authored
修复indexes、tabs 在h5端无法自动滚动到可视区的问题 (#1548)
* docs: 修复按需引入组件路径的问题 `at-search-bar` 路径会被识别成 `search` 而不是 `search-bar` * fix: 修复indexes、tabs 在h5端无法自动滚动到可视区的问题 Co-authored-by: 张宁宁 <[email protected]>
1 parent 8e9a7bd commit 7f9c610

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

packages/taro-ui/src/components/indexes/index.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default class AtIndexes extends React.Component<
8282

8383
if (ENV === Taro.ENV_TYPE.WEB) {
8484
delayQuerySelector('.at-indexes', 0).then(rect => {
85-
const targetOffsetTop = this.listRef.childNodes[idx].offsetTop
85+
const targetOffsetTop = this.listRef.children[idx].offsetTop
8686
const _scrollTop = targetOffsetTop - rect[0].top
8787
this.updateState({
8888
_scrollTop,
@@ -173,13 +173,8 @@ export default class AtIndexes extends React.Component<
173173

174174
public render(): JSX.Element {
175175
const { className, customStyle, animation, topKey, list } = this.props
176-
const {
177-
_scrollTop,
178-
_scrollIntoView,
179-
_tipText,
180-
_isShowToast,
181-
isWEB
182-
} = this.state
176+
const { _scrollTop, _scrollIntoView, _tipText, _isShowToast, isWEB } =
177+
this.state
183178

184179
const toastStyle = { minWidth: pxTransform(100) }
185180
const rootCls = classNames('at-indexes', className)

packages/taro-ui/src/components/tabs/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default class AtTabs extends React.Component<AtTabsProps, AtTabsState> {
5555
}
5656
case Taro.ENV_TYPE.WEB: {
5757
const index = Math.max(idx - 1, 0)
58-
const prevTabItem = this.tabHeaderRef.childNodes[index]
58+
const prevTabItem = this.tabHeaderRef.children[index]
5959
prevTabItem &&
6060
this.setState({
6161
_scrollTop: prevTabItem.offsetTop,

0 commit comments

Comments
 (0)