Skip to content

Conversation

vdegenne
Copy link
Contributor

@vdegenne vdegenne commented Sep 5, 2024

Proposing this helper function to quickly retrieve the activated item in the list.

@vdegenne vdegenne changed the title feat(list): add activatedItem getter feat(list): add activeItem getter Sep 5, 2024
* @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() {
Copy link
Collaborator

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.
Copy link
Collaborator

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;
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants