Skip to content

Changed List to add onActive #6103

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

Merged
merged 3 commits into from
May 2, 2022
Merged

Changed List to add onActive #6103

merged 3 commits into from
May 2, 2022

Conversation

ericsoderberghp
Copy link
Contributor

What does this PR do?

Exposes the internal active state of a List via onActive.
Also ensures that any onKeyDown passed in is given to the internal Keyboard.

Where should the reviewer start?

I'd start by reading the unit test changes. They should give an idea on what is happening.

What testing has been done on this PR?

Enhanced unit tests.
Did some manual testing with the onClickItem story by adding onActive and onKeyDown

I didn't add a storybook story for this as it seemed somewhat obscure and reasonably covered by the unit tests.

How should this be manually tested?

Add your own onActive and onKeyDown to a story.

Do Jest tests follow these best practices?

followed existing test structure

What are the relevant issues?

#6087

Do the grommet docs need to be updated?

yes

Should this PR be mentioned in the release notes?

yes

Is this change backwards compatible or is it a breaking change?

backwards compatible

@@ -151,8 +153,15 @@ const List = React.forwardRef(
// If onOrder is not defined but onClickItem is (e.g. the
// List items are likely selectable), active will be the
// index of the item which is currently active.
const [active, setActive] = useState();
const [active, setActiveState] = useState();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we rename active to activeState ? no change to functionality but we typically have kept these variable names tied together.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to leave setActive as was and changed new function to be updateActive, to make it clear it wasn't just updating a useState

Copy link
Collaborator

@taysea taysea left a comment

Choose a reason for hiding this comment

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

All looks good, soft opinion on my previous comment.

Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

Looks good!

@ericsoderberghp ericsoderberghp merged commit fe30835 into master May 2, 2022
@ericsoderberghp ericsoderberghp deleted the feat/list-onactive branch May 2, 2022 19:33
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.

List — Expose left/right arrow key events and active element
3 participants