Skip to content
New issue

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

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

Already on GitHub? # to your account

[HierarchyList] Test coverage, conditional rendering, and defaultSelected expansion #904

Merged
merged 7 commits into from
Feb 17, 2020

Conversation

sstone2423
Copy link

@sstone2423 sstone2423 commented Feb 13, 2020

Closes #892

Summary

  • Coverage was failing as it was under 80%
  • The secondaryValue div was still being rendered, even when it was null
  • The defaultSelectId's parent elements are now expanded by default
  • List scrolls to the defaultSelectedId

Change List (commits, features, bugs, etc)

  • Additional tests added to rise to >80%
  • Conditional rendering added to ListItem. If secondaryValue is null, it will not render, freeing up the other 50% of the width
  • Additional functions for recursively searching were added to find items by id
  • New story added to show defaultSelectedId behavior
  • toBeTruthy() functions renamed to toBeInTheDocument() where applicable to give a better idea of what I am actually testing for
  • Ref added to defaultSelectedId's DOM element
    • Custom hook magic to determine if the node is set before trying to scroll

Acceptance Test (how to verify the PR)

  • See the 'with defaultSelectedId' HierarchyList story and see that an item is pre-selected, its parent is expanded, and the element is scrolled into view

@netlify
Copy link

netlify bot commented Feb 13, 2020

Deploy preview for carbon-addons-iot-react ready!

Built with commit b070956

https://deploy-preview-904--carbon-addons-iot-react.netlify.com

@sstone2423 sstone2423 reopened this Feb 17, 2020
export const searchForItemId = (item, searchId) => {
if (
// Check if the value or secondary value has a match
item.id.toLowerCase().search(searchId.toLowerCase()) !== -1
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't this function and searchForItemValue be refactored into one to take a list of content keys to search for so the same codebase can be shared?

Copy link
Author

Choose a reason for hiding this comment

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

Refactored and made a general util search function

Copy link
Contributor

@scottdickerson scottdickerson left a comment

Choose a reason for hiding this comment

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

LGTM

@scottdickerson scottdickerson merged commit 35c117c into master Feb 17, 2020
@tay1orjones tay1orjones deleted the hierarchylist branch February 17, 2020 19:43
@tay1orjones
Copy link
Member

🎉 This PR is included in version 2.42.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

[HierarchyList] If I start the list with a child element selected, the parent is collapsed
4 participants