From 95df17eed56e8135e837fb2f9bd23b0944e502f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=8B?= Date: Sun, 14 May 2023 22:52:20 +0800 Subject: [PATCH 1/4] feat: add List ScrollBar direction --- src/OptionList.tsx | 2 ++ src/Select.tsx | 5 +++++ src/SelectContext.ts | 1 + 3 files changed, 8 insertions(+) diff --git a/src/OptionList.tsx b/src/OptionList.tsx index 7208a88fc..dd4f034d1 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -53,6 +53,7 @@ const OptionList: React.ForwardRefRenderFunction = (_, r rawValues, fieldNames, virtual, + direction, listHeight, listItemHeight, } = React.useContext(SelectContext); @@ -297,6 +298,7 @@ const OptionList: React.ForwardRefRenderFunction = (_, r onMouseDown={onListMouseDown} onScroll={onPopupScroll} virtual={virtual} + direction={direction} innerProps={virtual ? null : a11yProps} > {(item, itemIndex) => { diff --git a/src/Select.tsx b/src/Select.tsx index 51e36359d..7baf410c9 100644 --- a/src/Select.tsx +++ b/src/Select.tsx @@ -139,6 +139,7 @@ export interface SelectProps>> Values displayValues={displayValues} onDisplayValuesChange={onDisplayValuesChange} + // >>> Trigger + direction={direction} // >>> Search searchValue={mergedSearchValue} onSearch={onInternalSearch} diff --git a/src/SelectContext.ts b/src/SelectContext.ts index ed9ffea25..d6cf9372d 100644 --- a/src/SelectContext.ts +++ b/src/SelectContext.ts @@ -14,6 +14,7 @@ export interface SelectContextProps { rawValues: Set; fieldNames?: FieldNames; virtual?: boolean; + direction?: "ltr" | "rtl"; listHeight?: number; listItemHeight?: number; childrenAsData?: boolean; From 4c22f75e74c3dfe95bfbcec78024e9b14d066ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=8B?= Date: Tue, 16 May 2023 10:59:04 +0800 Subject: [PATCH 2/4] chore: update snapshots --- package.json | 2 +- tests/__snapshots__/Select.test.tsx.snap | 8 ++++---- tests/__snapshots__/Tags.test.tsx.snap | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index dcca9d421..d08f1c08a 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "rc-motion": "^2.0.1", "rc-overflow": "^1.0.0", "rc-util": "^5.16.1", - "rc-virtual-list": "^3.4.13" + "rc-virtual-list": "^3.5.1" }, "devDependencies": { "@testing-library/jest-dom": "^5.16.5", diff --git a/tests/__snapshots__/Select.test.tsx.snap b/tests/__snapshots__/Select.test.tsx.snap index 15d7f073b..6697f1d73 100644 --- a/tests/__snapshots__/Select.test.tsx.snap +++ b/tests/__snapshots__/Select.test.tsx.snap @@ -3,7 +3,7 @@ exports[`Select.Basic does not filter when filterOption value is false 1`] = `
diff --git a/tests/__snapshots__/Tags.test.tsx.snap b/tests/__snapshots__/Tags.test.tsx.snap index 0bef74b2c..64abc8eeb 100644 --- a/tests/__snapshots__/Tags.test.tsx.snap +++ b/tests/__snapshots__/Tags.test.tsx.snap @@ -100,7 +100,7 @@ exports[`Select.Tags OptGroup renders correctly 1`] = `
Date: Wed, 17 May 2023 10:36:39 +0800 Subject: [PATCH 3/4] chore: empty test --- tests/Select.test.tsx | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index 8dd12c3fb..ebdb77947 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -1925,31 +1925,18 @@ describe('Select.Basic', () => { }); it('should support title', () => { - const wrapper1 = mount( - ); expect(wrapper1.find('.rc-select').prop('title')).toBe(undefined); expect(wrapper1.find('.rc-select-selection-item').prop('title')).toBe('lucy'); - const wrapper2 = mount( - ); expect(wrapper2.find('.rc-select').prop('title')).toBe(''); expect(wrapper2.find('.rc-select-selection-item').prop('title')).toBe(''); - const wrapper3 = mount( - ); expect(wrapper3.find('.rc-select').prop('title')).toBe('title'); expect(wrapper3.find('.rc-select-selection-item').prop('title')).toBe('title'); }); + + it('scrollbar should be left position with rtl direction', () => { + + }); }); From fadd3952ef812c9295b490fcf860546911a09f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E6=9C=BA=E5=99=A8=E4=BA=BA?= Date: Thu, 18 May 2023 11:41:23 +0800 Subject: [PATCH 4/4] test: update test case --- package.json | 2 +- tests/Select.test.tsx | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d08f1c08a..4a35f4ab9 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "rc-motion": "^2.0.1", "rc-overflow": "^1.0.0", "rc-util": "^5.16.1", - "rc-virtual-list": "^3.5.1" + "rc-virtual-list": "^3.5.2" }, "devDependencies": { "@testing-library/jest-dom": "^5.16.5", diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index ebdb77947..a88e5345d 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -1937,6 +1937,9 @@ describe('Select.Basic', () => { }); it('scrollbar should be left position with rtl direction', () => { - + const options = new Array(10).fill(null).map((_, value) => ({ value })); + + const { container } = testingRender(