Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add pageSize prop to render initial number of items in dropdown #498 #665

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,16 @@
"contributions": [
"code"
]
},
{
"login": "ParthSatasiya",
"name": "Parth Satasiya",
"avatar_url": "https://avatars.githubusercontent.com/u/31753548?v=4",
"profile": "https://github.com/ParthSatasiya",
"contributions": [
"question",
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ A lightweight and fast control to render a select component that can display hie
- [id](#id)
- [searchPredicate](#searchpredicate)
- [inlineSearchInput](#inlinesearchinput)
- [pageSize](#pageSize)
- [tabIndex](#tabIndex)
- [disablePoppingOnBackspace](#disablePoppingOnBackspace)
- [Styling and Customization](#styling-and-customization)
Expand Down Expand Up @@ -416,6 +417,12 @@ Type: `bool` (default: `false`)

`inlineSearchInput=true` makes the search input renders **inside** the dropdown-content. This can be useful when your UX looks something like [this comment](https://github.com/dowjones/react-dropdown-tree-select/issues/308#issue-526467109).

### pageSize

Type: `number` (default: `100`)

`pageSize=100` attribute indicates how many elements will render initially on the dropdown. When the scroll is near the end of the list at that time it automatically renders the next `100` elements in the dropdown.

### tabIndex

Type: `number` (default: `0`)
Expand Down Expand Up @@ -659,6 +666,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
<td align="center"><a href="http://osmancode.me"><img src="https://avatars0.githubusercontent.com/u/1795294?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mohamad Othman</b></sub></a><br /><a href="https://github.com/dowjones/react-dropdown-tree-select/commits?author=osmancode" title="Code">💻</a> <a href="#ideas-osmancode" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://github.com/smurfs2549"><img src="https://avatars3.githubusercontent.com/u/8286468?v=4?s=100" width="100px;" alt=""/><br /><sub><b>kathleenlu</b></sub></a><br /><a href="https://github.com/dowjones/react-dropdown-tree-select/commits?author=smurfs2549" title="Code">💻</a> <a href="https://github.com/dowjones/react-dropdown-tree-select/issues?q=author%3Asmurfs2549" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/r-zane-spalding"><img src="https://avatars.githubusercontent.com/u/88853042?v=4?s=100" width="100px;" alt=""/><br /><sub><b>r-zane-spalding</b></sub></a><br /><a href="https://github.com/dowjones/react-dropdown-tree-select/commits?author=r-zane-spalding" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ParthSatasiya"><img src="https://avatars.githubusercontent.com/u/31753548?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Parth Satasiya</b></sub></a><br /><a href="https://github.com/dowjones/react-dropdown-tree-select/commits?author=ParthSatasiya" title="Code">💻</a></td>
</tr>
</table>

Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class DropdownTreeSelect extends Component {
id: PropTypes.string,
searchPredicate: PropTypes.func,
inlineSearchInput: PropTypes.bool,
pageSize: PropTypes.number,
tabIndex: PropTypes.number,
disablePoppingOnBackspace: PropTypes.bool,
}
Expand All @@ -60,6 +61,7 @@ class DropdownTreeSelect extends Component {
texts: {},
showDropdown: 'default',
inlineSearchInput: false,
pageSize: 100,
tabIndex: 0,
disablePoppingOnBackspace: false,
}
Expand Down Expand Up @@ -362,6 +364,7 @@ class DropdownTreeSelect extends Component {
onAction={this.onAction}
onCheckboxChange={this.onCheckboxChange}
onNodeToggle={this.onNodeToggle}
pageSize={this.props.pageSize}
mode={mode}
showPartiallySelected={this.props.showPartiallySelected}
{...commonProps}
Expand Down
2 changes: 2 additions & 0 deletions types/react-dropdown-tree-select.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ declare module 'react-dropdown-tree-select' {
* search bar, the tree will not deselect nodes.
*/
disablePoppingOnBackspace?: boolean
/** `pageSize=100` attribute indicates how many elements will render initially on the dropdown. When the scroll is near the end of the list at that time it automatically renders the next `100` elements in the dropdown. */
pageSize?: number
}

export interface DropdownTreeSelectState {
Expand Down
Loading