You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
refactor(list): Refactor list item management (#413)
BREAKING CHANGE: Event handlers moved from list to list item. New props on list item for focus, follow href, toggle checkbox, and classnames/attributes passed down from list. Remove ID prop from list item.
Copy file name to clipboardExpand all lines: packages/list/README.md
+17-8Lines changed: 17 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,8 @@ class MyApp extends Component {
49
49
}
50
50
```
51
51
52
+
> _NOTE_: Please use the `ListItem` component to specify list items. `List` will not recognize custom list item components.
53
+
52
54
## Variants
53
55
54
56
### Two-Line List
@@ -140,7 +142,9 @@ class MyApp extends Component {
140
142
141
143
### Single Selection
142
144
143
-
You can use the `singleSelection` Boolean prop for `List` to allow for selection of list items. You can also set the `selectedIndex` of the list programmatically.
145
+
You can use the `singleSelection` Boolean prop for `List` to allow for selection of list items. You can also set the `selectedIndex` of the list programmatically and include a `handleSelect` callback.
146
+
147
+
> _NOTE_: If you are inserting or removing list items, you must update the `selectedIndex` accordingly.
144
148
145
149
```js
146
150
classMyAppextendsReact.Component {
@@ -153,6 +157,7 @@ class MyApp extends React.Component {
dense | Boolean | Styles the density of the list, making it appear more compact
181
186
avatarList | Boolean | Configures the leading tiles of each row to display images instead of icons. This will make the graphics of the list items larger
182
187
twoLine | Boolean | Styles the list with two lines
183
188
singleSelection | Boolean | Allows for single selection of list items
184
189
wrapFocus | Boolean | Sets the list to allow the up arrow on the first element to focus the last element of the list and vice versa
185
190
selectedIndex | Number | Toggles the selected state of the list item at the given index
191
+
handleSelect | Function(selectedIndex: Number) => void | Callback for handling a list item selection event
186
192
aria-orientation | String | Indicates the list orientation
187
-
onClick | Function(evt: Event) => void | Callback for handling a click event
188
-
onKeyDown | Function(evt: Event) => void | Callback for handling a keydown event
189
-
onFocus | Function(evt: Event) => void | Callback for handling a focus event
190
-
onBlur | Function(evt: Event) => void | Callback for handling a blur event
191
193
192
194
### ListItem
193
195
194
196
Prop Name | Type | Description
195
197
--- | --- | ---
196
-
id | String | Unique identifier for the list item. Defaults to the index
197
198
className | String | Classes to be applied to the list item element
199
+
classNamesFromList | Array<String> | Additional classes to be applied to the list item element, passed down from list
200
+
attributesFromList | Additional attributes to be applied to the list item element, passed down from list
198
201
childrenTabIndex | Number | Tab index to be applied to all children of the list item
199
-
init | Function() => void | Callback executed when list item mounts
202
+
shouldFocus | Whether to focus the list item
203
+
shouldFollowHref | Whether to follow the link indicated by the list item
204
+
shouldToggleCheckbox | Whether to toggle the checkbox on the list item
205
+
onClick | Function(evt: Event) => void | Callback for handling a click event
206
+
onKeyDown | Function(evt: Event) => void | Callback for handling a keydown event
207
+
onFocus | Function(evt: Event) => void | Callback for handling a focus event
208
+
onBlur | Function(evt: Event) => void | Callback for handling a blur event
0 commit comments