Skip to content

Commit

Permalink
修复indexes、tabs 在h5端无法自动滚动到可视区的问题 (jd-opensource#1548)
Browse files Browse the repository at this point in the history
* docs: 修复按需引入组件路径的问题

`at-search-bar` 路径会被识别成 `search` 而不是 `search-bar`

* fix: 修复indexes、tabs 在h5端无法自动滚动到可视区的问题

Co-authored-by: 张宁宁 <[email protected]>
  • Loading branch information
luckymore and 张宁宁 authored Dec 30, 2022
1 parent 8e9a7bd commit 7f9c610
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions packages/taro-ui/src/components/indexes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class AtIndexes extends React.Component<

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

public render(): JSX.Element {
const { className, customStyle, animation, topKey, list } = this.props
const {
_scrollTop,
_scrollIntoView,
_tipText,
_isShowToast,
isWEB
} = this.state
const { _scrollTop, _scrollIntoView, _tipText, _isShowToast, isWEB } =
this.state

const toastStyle = { minWidth: pxTransform(100) }
const rootCls = classNames('at-indexes', className)
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-ui/src/components/tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class AtTabs extends React.Component<AtTabsProps, AtTabsState> {
}
case Taro.ENV_TYPE.WEB: {
const index = Math.max(idx - 1, 0)
const prevTabItem = this.tabHeaderRef.childNodes[index]
const prevTabItem = this.tabHeaderRef.children[index]
prevTabItem &&
this.setState({
_scrollTop: prevTabItem.offsetTop,
Expand Down

0 comments on commit 7f9c610

Please sign in to comment.