Skip to content

Commit 52f36a8

Browse files
committed
feat: OptionList will get direction props
1 parent c350482 commit 52f36a8

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/OptionList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface OptionListProps<OptionsType extends object[]> {
3636
childrenAsData: boolean;
3737
searchValue: string;
3838
virtual: boolean;
39+
direction?: 'ltr' | 'rtl';
3940

4041
onSelect: (value: RawValueType, option: { selected: boolean }) => void;
4142
onToggleOpen: (open?: boolean) => void;
@@ -57,7 +58,7 @@ export interface RefOptionListProps {
5758
* Using virtual list of option display.
5859
* Will fallback to dom if use customize render.
5960
*/
60-
const OptionList: React.RefForwardingComponent<
61+
const OptionList: React.ForwardRefRenderFunction<
6162
RefOptionListProps,
6263
OptionListProps<SelectOptionsType>
6364
> = (

src/generate.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export interface SelectProps<OptionsType extends object[], ValueType> extends Re
125125
animation?: string;
126126
transitionName?: string;
127127
getPopupContainer?: RenderDOMFunc;
128-
direction?: string;
128+
direction?: 'ltr' | 'rtl';
129129

130130
// Others
131131
disabled?: boolean;
@@ -985,6 +985,7 @@ export default function generateSelector<
985985
menuItemSelectedIcon={menuItemSelectedIcon}
986986
virtual={virtual !== false && dropdownMatchSelectWidth !== false}
987987
onMouseEnter={onPopupMouseEnter}
988+
direction={direction}
988989
/>
989990
);
990991

tests/Select.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,14 @@ describe('Select.Basic', () => {
208208

209209
it('should direction rtl', () => {
210210
const wrapper = mount(
211-
<Select direction="rtl">
211+
<Select direction="rtl" open>
212212
<Option value="1">1</Option>
213213
<Option value="2">2</Option>
214214
</Select>,
215215
);
216216
expect(wrapper.find('Trigger').props().popupPlacement).toBe('bottomRight');
217+
218+
expect(wrapper.find('OptionList').props().direction).toEqual('rtl');
217219
});
218220

219221
it('should not response click event when select is disabled', () => {

0 commit comments

Comments
 (0)