Skip to content

Commit

Permalink
fix(listProps): fix properties in listProps to be optional (#2622)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonguo committed Jul 28, 2022
1 parent e4f7511 commit 650abbd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Picker/DropdownMenu.tsx
Expand Up @@ -36,7 +36,7 @@ export interface DropdownMenuProps<Multiple = false>
virtualized?: boolean;

// https://github.com/bvaughn/react-virtualized/blob/master/docs/List.md#prop-types
listProps?: ListProps;
listProps?: Partial<ListProps>;

/** Custom selected option */
renderMenuItem?: (itemLabel: React.ReactNode, item: any) => React.ReactNode;
Expand Down
4 changes: 2 additions & 2 deletions src/SelectPicker/SelectPicker.tsx
Expand Up @@ -36,8 +36,8 @@ import {
PickerToggleProps
} from '../Picker';

import { ListProps } from '../Picker/VirtualizedList';
import { FormControlPickerProps, ItemDataType } from '../@types/common';
import { ListProps } from 'react-virtualized/dist/commonjs/List';

export interface SelectProps<T> {
/** Set group condition key in data */
Expand All @@ -53,7 +53,7 @@ export interface SelectProps<T> {
* List-related properties in `react-virtualized`
* https://github.com/bvaughn/react-virtualized/blob/master/docs/List.md#prop-types
*/
listProps?: ListProps;
listProps?: Partial<ListProps>;

/** Custom search rules. */
searchBy?: (keyword: string, label: React.ReactNode, item: ItemDataType) => boolean;
Expand Down
3 changes: 3 additions & 0 deletions src/SelectPicker/test/SelectPicker.test.tsx
Expand Up @@ -54,3 +54,6 @@ type SortDirection = 'asc' | 'desc';
/>;

<SelectPicker caretAs={() => <div />} data={[]} />;

// Override the default value of listProps.
<SelectPicker data={[]} virtualized listProps={{ rowHeight: 70 }} />;
4 changes: 2 additions & 2 deletions src/Tree/Tree.tsx
Expand Up @@ -2,7 +2,7 @@ import React, { useMemo } from 'react';
import TreePicker from '../TreePicker';
import TreeContext from './TreeContext';
import { StandardProps, ItemDataType, RsRefForwardingComponent } from '../@types/common';
import { ListProps } from 'react-virtualized/dist/commonjs/List';
import { ListProps } from '../Picker/VirtualizedList';

/**
* Tree Node Drag Type
Expand Down Expand Up @@ -71,7 +71,7 @@ export interface TreeBaseProps<ValueType = string | number, ItemDataType = Recor
* List-related properties in `react-virtualized`
* https://github.com/bvaughn/react-virtualized/blob/master/docs/List.md#prop-types
*/
listProps?: ListProps;
listProps?: Partial<ListProps>;

/** Expand all nodes By default */
defaultExpandAll?: boolean;
Expand Down
5 changes: 5 additions & 0 deletions src/Tree/test/Tree.test.tsx
@@ -0,0 +1,5 @@
import React from 'react';
import Tree from '../Tree';

// Override the default value of listProps.
<Tree data={[]} virtualized listProps={{ rowHeight: 70 }} />;

1 comment on commit 650abbd

@vercel
Copy link

@vercel vercel bot commented on 650abbd Jul 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.