Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修改 updateScroll 调用时机 #1110

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions compiled/alipay/src/Tabs/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { useEffect, useState } from 'functional-mini/compat';
import { useEvent, useReady, useRef } from 'functional-mini/component';
import { useState } from 'functional-mini/compat';
import {
useDidMount,
useEvent,
useReady,
useRef,
} from 'functional-mini/component';
import '../_util/assert-component2';
import { mountComponent } from '../_util/component';
import { useComponentEvent } from '../_util/hooks/useComponentEvent';
Expand Down Expand Up @@ -66,6 +71,9 @@
(id) => `#ant-tabs-bar-item${id}-${current}`
),
]);
if (!view || !item) {
return;

Check warning on line 75 in compiled/alipay/src/Tabs/index.ts

View check run for this annotation

Codecov / codecov/patch

compiled/alipay/src/Tabs/index.ts#L75

Added line #L75 was not covered by tests
}

if (props.direction === 'vertical') {
let scrollTop = scrollRef.current.scrollTop || 0;
Expand Down Expand Up @@ -144,7 +152,7 @@
triggerEvent('change', index, e);
});

useEffect(() => {
useDidMount(() => {
updateScroll();
}, []);

Expand Down
5 changes: 4 additions & 1 deletion compiled/wechat/src/Tabs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
}
};
import { useState } from 'functional-mini/compat';
import { useEvent, useReady, useRef } from 'functional-mini/component';
import { useEvent, useReady, useRef, } from 'functional-mini/component';
import '../_util/assert-component2';
import { mountComponent } from '../_util/component';
import { useComponentEvent } from '../_util/hooks/useComponentEvent';
Expand Down Expand Up @@ -106,6 +106,9 @@ var Tabs = function (props) {
])];
case 1:
_a = _b.sent(), view = _a[0], item = _a[1];
if (!view || !item) {
return [2 /*return*/];
}
if (props.direction === 'vertical') {
scrollTop = scrollRef.current.scrollTop || 0;
needScroll_1 = false;
Expand Down
14 changes: 11 additions & 3 deletions src/Tabs/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { useEffect, useState } from 'functional-mini/compat';
import { useEvent, useReady, useRef } from 'functional-mini/component';
import { useState } from 'functional-mini/compat';
import {
useDidMount,
useEvent,
useReady,
useRef,
} from 'functional-mini/component';
import '../_util/assert-component2';
import { mountComponent } from '../_util/component';
import { useComponentEvent } from '../_util/hooks/useComponentEvent';
Expand Down Expand Up @@ -66,6 +71,9 @@ const Tabs = (props: ITabsProps) => {
(id) => `#ant-tabs-bar-item${id}-${current}`
),
]);
if (!view || !item) {
return;
}

if (props.direction === 'vertical') {
let scrollTop = scrollRef.current.scrollTop || 0;
Expand Down Expand Up @@ -145,7 +153,7 @@ const Tabs = (props: ITabsProps) => {
});

/// #if ALIPAY
useEffect(() => {
useDidMount(() => {
updateScroll();
}, []);
/// #endif
Expand Down
Loading