Skip to content
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(ktreelist): add collapse/expand option [KHCP-14716] #2583

Conversation

DariaYeremina
Copy link
Contributor

@DariaYeremina DariaYeremina commented Jan 20, 2025

Summary

https://konghq.atlassian.net/browse/KHCP-14716

  • add collapsible prop to enable collapse/expand feature.
  • add collapseAll prop to allow initial collapse/expand for all items.
  • add docs
  • add component tests

image

@DariaYeremina DariaYeremina self-assigned this Jan 20, 2025
Copy link

netlify bot commented Jan 20, 2025

Deploy Preview for kongponents-sandbox ready!

Name Link
🔨 Latest commit 08810f4
🔍 Latest deploy log https://app.netlify.com/sites/kongponents-sandbox/deploys/679136cca5a71600085a2f40
😎 Deploy Preview https://deploy-preview-2583--kongponents-sandbox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 20, 2025

Deploy Preview for kongponents ready!

Name Link
🔨 Latest commit 08810f4
🔍 Latest deploy log https://app.netlify.com/sites/kongponents/deploys/679136ccb4e8f500082ddbf8
😎 Deploy Preview https://deploy-preview-2583--kongponents.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@DariaYeremina DariaYeremina marked this pull request as ready for review January 20, 2025 20:09
src/components/KTreeList/KTreeItem.vue Outdated Show resolved Hide resolved
docs/components/tree-list.md Outdated Show resolved Hide resolved
docs/components/tree-list.md Outdated Show resolved Hide resolved
src/components/KTreeList/KTreeDraggable.vue Show resolved Hide resolved
src/components/KTreeList/KTreeDraggable.vue Outdated Show resolved Hide resolved
src/components/KTreeList/KTreeItem.vue Show resolved Hide resolved
src/components/KTreeList/KTreeItem.vue Outdated Show resolved Hide resolved
src/components/KTreeList/KTreeItem.vue Show resolved Hide resolved
src/components/KTreeList/KTreeItem.vue Show resolved Hide resolved
docs/components/tree-list.md Outdated Show resolved Hide resolved
src/components/KTreeList/KTreeItem.vue Outdated Show resolved Hide resolved
@adamdehaven
Copy link
Member

image

The indentation here needs to be tweaked so that all of the top-level items are aligned on the left, and the children are indented visually to the right of the parent

@DariaYeremina DariaYeremina force-pushed the feat/KHCP-14716-enhance-k-tree-list-to-support-collapsable-parent-items branch from 31e0e4a to 9249d08 Compare January 21, 2025 19:17
docs/components/tree-list.md Show resolved Hide resolved
docs/components/tree-list.md Outdated Show resolved Hide resolved
v-if="hasIcon"
class="tree-item-icon"
data-testid="tree-item-icon"
<ChevronDownIcon
Copy link
Member

@adamdehaven adamdehaven Jan 21, 2025

Choose a reason for hiding this comment

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

A few issues:

  1. The chevron should point "down" when expanded, and "right" when collapsed.
  2. Clicking the button seems to toggle the icon direction.
  3. I can tab to the icon to collapse/expand but dont have a way to actually trigger it
  4. After reordering the items, but not touching collapse icon button, the icon direction seems to change on the docs site.
  5. After reordering, I can no longer expand/collapse the items on the first click consistently. Sometimes it takes several clicks.

@adamdehaven
Copy link
Member

image

For a child node that itself is not expandable, can we remove the "gap" on the left between the item and the line?

Comment on lines 286 to 291
// set previous icon state after DOM was re-rendered
await nextTick(() => {
treeItems.value?.forEach((item: typeof KTreeItem) => {
item?.setExpandedValue(childrenVisibilityMap.value.get(item?.id))
})
})
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we update the syntax here to match the other usage in the repo?

Suggested change
// set previous icon state after DOM was re-rendered
await nextTick(() => {
treeItems.value?.forEach((item: typeof KTreeItem) => {
item?.setExpandedValue(childrenVisibilityMap.value.get(item?.id))
})
})
// set previous icon state after DOM was re-rendered
await nextTick()
treeItems.value?.forEach((item: typeof KTreeItem) => {
item?.setExpandedValue(childrenVisibilityMap.value.get(item?.id))
})

Comment on lines 331 to 335
await nextTick(() => {
if (props.collapsible) {
triggerCollapse()
}
})
Copy link
Member

Choose a reason for hiding this comment

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

ah can we update the syntax here as well?

Copy link
Member

@adamdehaven adamdehaven left a comment

Choose a reason for hiding this comment

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

lgtm

@DariaYeremina DariaYeremina merged commit a5490a3 into main Jan 22, 2025
10 checks passed
@DariaYeremina DariaYeremina deleted the feat/KHCP-14716-enhance-k-tree-list-to-support-collapsable-parent-items branch January 22, 2025 18:29
kongponents-bot pushed a commit that referenced this pull request Jan 22, 2025
# [9.18.0](v9.17.5...v9.18.0) (2025-01-22)

### Features

* **ktreelist:** add collapse/expand option [KHCP-14716] ([#2583](#2583)) ([a5490a3](a5490a3))
@kongponents-bot
Copy link
Collaborator

🎉 This PR is included in version 9.18.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

5 participants