-
Notifications
You must be signed in to change notification settings - Fork 892
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(list): add activeItem getter #5704
base: main
Are you sure you want to change the base?
Conversation
* @return A record of the first activated item including the item and the | ||
* index of the item or `null` if none are activated. | ||
*/ | ||
get activeItem() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this above next to the other get items()
property and add @export
to the jsdoc?
@@ -90,4 +90,14 @@ export class List extends LitElement { | |||
activatePreviousItem(): ListItem | null { | |||
return this.listController.activatePreviousItem(); | |||
} | |||
|
|||
/** | |||
* Retrieves the first activated item of the array of items. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "array of items, or null." to be more explicit
* index of the item or `null` if none are activated. | ||
*/ | ||
get activeItem() { | ||
return this.listController.activeItem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should expose the {item, index}
object that the controller uses. Instead, I would suggest separate activeItem
and activeItemIndex
properties, like how tabs work.
Proposing this helper function to quickly retrieve the activated item in the list.