From af6fcda075f948ce63a3edd99cda5e44762f2494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=8B?= <94534613+BoyYangzai@users.noreply.github.com> Date: Thu, 18 May 2023 17:15:42 +0800 Subject: [PATCH] feat: add List ScrollBar direction (#940) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add List ScrollBar direction * chore: update snapshots * chore: empty test * test: update test case --------- Co-authored-by: 洋 Co-authored-by: 二货机器人 --- package.json | 2 +- src/OptionList.tsx | 2 ++ src/Select.tsx | 5 +++++ src/SelectContext.ts | 1 + tests/Select.test.tsx | 7 +++++++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index dcca9d421..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.4.13" + "rc-virtual-list": "^3.5.2" }, "devDependencies": { "@testing-library/jest-dom": "^5.16.5", 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 8ec4b05ab..7d5f17040 100644 --- a/src/Select.tsx +++ b/src/Select.tsx @@ -140,6 +140,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; diff --git a/tests/Select.test.tsx b/tests/Select.test.tsx index 8c23d3661..0be3d3304 100644 --- a/tests/Select.test.tsx +++ b/tests/Select.test.tsx @@ -1980,4 +1980,11 @@ describe('Select.Basic', () => { 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', () => { + const options = new Array(10).fill(null).map((_, value) => ({ value })); + + const { container } = testingRender(