From dcfec98987aa721e0f53bae9d16dafbd677b5104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Fri, 22 Dec 2023 10:39:39 +0800 Subject: [PATCH 01/64] enhance(Tabs): Add experimental prop `autoScroll` (#6497) * chore: init * feat: autoScroll disabled * chore: comment it --- src/components/tabs/tabs.tsx | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/components/tabs/tabs.tsx b/src/components/tabs/tabs.tsx index 751ed4473c..2bd099e135 100644 --- a/src/components/tabs/tabs.tsx +++ b/src/components/tabs/tabs.tsx @@ -35,6 +35,12 @@ export type TabsProps = { onChange?: (key: string) => void children?: ReactNode direction?: 'ltr' | 'rtl' + /** + * @experimental Support disabled auto scroll when Tabs header content change. + * This API name or function may change in the future. + * Please lock the version if you want to use it. + */ + autoScroll?: boolean } & NativeProps< | '--fixed-active-line-width' | '--active-line-height' @@ -83,7 +89,7 @@ export const Tabs: FC = p => { }, }) - const [{ x, width }, api] = useSpring(() => ({ + const [{ x, width }, inkApi] = useSpring(() => ({ x: 0, width: 0, config: { @@ -108,12 +114,13 @@ export const Tabs: FC = p => { }, })) - function animate(immediate = false) { + function animate(immediate = false, fromMutation = false) { const container = tabListContainerRef.current if (!container) return + const activeIndex = keyToIndexRecord[activeKey as string] if (activeIndex === undefined) { - api.start({ + inkApi.start({ x: 0, width: 0, immediate: true, @@ -161,7 +168,7 @@ export const Tabs: FC = p => { x = -(containerWidth - x - w) } - api.start({ + inkApi.start({ x, width, immediate, @@ -193,11 +200,13 @@ export const Tabs: FC = p => { ) } - scrollApi.start({ - scrollLeft: nextScrollLeft, - from: { scrollLeft: containerScrollLeft }, - immediate, - }) + if (!fromMutation || props.autoScroll !== false) { + scrollApi.start({ + scrollLeft: nextScrollLeft, + from: { scrollLeft: containerScrollLeft }, + immediate, + }) + } } useIsomorphicLayoutEffect(() => { @@ -214,7 +223,7 @@ export const Tabs: FC = p => { useMutationEffect( () => { - animate(!x.isAnimating) + animate(!x.isAnimating, true) }, tabListContainerRef, { From d6f94ec0de0fa424769ad0873ce82f285e51252d Mon Sep 17 00:00:00 2001 From: majiang666 Date: Fri, 22 Dec 2023 16:52:30 +0800 Subject: [PATCH 02/64] =?UTF-8?q?enhance:=20=E4=BC=98=E5=8C=96=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E9=94=AE=E7=9B=98=E5=8F=8A=E8=99=9A=E6=8B=9F=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86=E6=97=A0=E9=9A=9C=E7=A2=8D=20(#6494)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 优化数字键盘及虚拟输入框无障碍 * fix: 优化test snapshots * chore: use locale * chore: update desc * test: fix img part * test: fix img part * test: fix img part * test: fix img test * test: rm useless snapshot * test: fix modal test * test: more test case * test: more test case * test: more test case * test: more test case * test: role check * test: rm fake timer --------- Co-authored-by: 二货机器人 --- jest.config.js | 2 +- .../__snapshots__/action-sheet.test.tsx.snap | 1 + src/components/dialog/tests/dialog.test.tsx | 8 ++++++- .../__snapshots__/image-viewer.test.tsx.snap | 1 + .../image-viewer/tests/image-viewer.test.tsx | 22 ++++++++++++++----- src/components/mask/mask.tsx | 1 + src/components/modal/tests/modal.test.tsx | 8 ++++++- .../number-keyboard/number-keyboard.tsx | 15 ++++++++----- .../tests/number-keyboard.test.tsx | 7 +++--- .../tests/virtual-input.test.tsx | 4 ++-- .../virtual-input/virtual-input.tsx | 2 +- src/tests/testing.tsx | 9 ++++++++ 12 files changed, 59 insertions(+), 21 deletions(-) diff --git a/jest.config.js b/jest.config.js index 9cf30a6087..9cf1772d76 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,7 @@ module.exports = { preset: 'ts-jest', testEnvironment: 'jsdom', - // maxConcurrency: 1, + maxConcurrency: 1, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], modulePathIgnorePatterns: ['/lib/', '/dist/'], moduleDirectories: ['node_modules', 'src/tests'], diff --git a/src/components/action-sheet/tests/__snapshots__/action-sheet.test.tsx.snap b/src/components/action-sheet/tests/__snapshots__/action-sheet.test.tsx.snap index 0f64c3b4be..14dcaea0e1 100644 --- a/src/components/action-sheet/tests/__snapshots__/action-sheet.test.tsx.snap +++ b/src/components/action-sheet/tests/__snapshots__/action-sheet.test.tsx.snap @@ -18,6 +18,7 @@ exports[`ActionSheet basic usage 1`] = ` class="adm-popup adm-action-sheet-popup" >